llvm-project
llvm-project copied to clipboard
[clang-tidy] readability-implicit-bool-conversion.AllowPointerConditions not honored
$ cat bool1.cpp
#include <cstdio>
bool OpenR(const char* filename) {
auto* file_ = fopen(filename, "rb");
return !file_;
}
$ /usr/local/clang-17/bin/clang-tidy -config="{Checks: '-*,readability-implicit-bool-conversion', CheckOptions: [{key: readability-implicit-bool-conversion.AllowPointerConditions, value: true}, {key: readability-implicit-bool-conversion.AllowIntegerConditions, value: true}]}" bool1.cpp --
1 warning generated.
/tmp/bool1.cpp:4:11: warning: implicit conversion 'FILE *' (aka '_IO_FILE *') -> bool [readability-implicit-bool-conversion]
4 | return !file_;
| ~^
| == nullptr
Since readability-implicit-bool-conversion.AllowPointerConditions is set to true, the warning should not be emitted.
Actually no bug here, as this isn't condition, option AllowPointerConditions covers only conditions, like "if (!file_)" and so on.
This makes this check not very useful for a code base where conversions between integral types and bool should be explicit but where conversions from pointer to bool are allowed.