[cfe-dev] clang-tidy: problem with readability-implicit-bool-conversion AllowPointerConditions
Simon Sandström via cfe-dev
cfe-dev at lists.llvm.org
Thu Sep 12 09:55:20 PDT 2019
Hello,
I'm getting an implicit conversion warning on a piece of code that (from
my understanding) I shouldn't. Most likely my understanding is incorrect
:-)
The piece of code is:
bool test1(const int* ptr, int other)
{
if (ptr) {
return *ptr == other;
}
return false;
}
bool test2(const int* ptr, int other)
{
return ptr && *ptr == other;
}
With AllowPointerConditions unset (0) I'm getting warnings both from
test1 and test2. With AllowPointerConditions set (1) I'm still getting a
warning from test2. Why is that? I guess that I don't understand the
'conditional' part of this option...
I'm using clang-tidy-8 (LLVM version 8.0.1) with the following
configuration:
-config="{Checks: '*', CheckOptions: [{key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1} ]}"
- Simon
More information about the cfe-dev
mailing list