Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

readability-implicit-bool-conversion assumes preprocessor macros return int #50602

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR51635
Status NEW
Importance P normal
Reported by Robert Ankeney (rrankene@gmail.com)
Reported on 2021-08-26 13:11:55 -0700
Last modified on 2021-08-27 16:36:05 -0700
Version unspecified
Hardware PC Linux
CC alexfh@google.com, djasper@google.com, greg.harmon@joby.aero, klimek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
For the following code:
#define test() true

int main()
{
   bool bVal = (true == test());
   return static_cast<int>(bVal == true);
}

clang-tidy -checks=readability-implicit-bool-conversion returns:
1 warning generated.
/tmp/t.cpp:5:17: warning: implicit conversion bool -> 'int' [readability-
implicit-bool-conversion]
   bool bVal = (true == test());
                ^~~~
                1

It appears clang-tidy assumes test() returns an int. Running the code through
the preprocessor first, followed by clang-tidy produces no warnings.
Quuxplusone commented 3 years ago

This is based on clang-tidy LLVM version 12.0.0