Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang-tidy bool-pointer-implicit-conversion does not warn about `return pointer_to_bool;` #37033

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR38060
Status NEW
Importance P enhancement
Reported by Chris Peterson (cpeterson@mozilla.com)
Reported on 2018-07-04 19:16:06 -0700
Last modified on 2019-09-07 06:08:02 -0700
Version unspecified
Hardware Macintosh All
CC alexfh@google.com, dblaikie@gmail.com, djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

clang-tidy logs only one bool-pointer-implicit-conversion warning for following code:

bool test(bool* pointer_to_bool) { if (pointer_to_bool) { // warning, as expected :) }

return pointer_to_bool; // no warning, but why not? :(

}

The return pointer_to_bool statement uses pointer_to_bool in a boolean expression but doesn't trigger a warning.

clang-tidy --checks="-*,misc-bool-pointer-implicit-conversion" bool-pointer-implicit-conversion.cpp

bool-pointer-implicit-conversion.cpp:5:7: warning: dubious check of 'bool ' against 'nullptr', did you mean to dereference it? [misc-bool-pointer-implicit-conversion] if (pointer_to_bool) { // warning ^

https://clang.llvm.org/extra/clang-tidy/checks/bugprone-bool-pointer-implicit-conversion.html

Quuxplusone commented 6 years ago

if (!pointer_to_bool) {} does not trigger a bool-pointer-implicit-conversion warning, either.