In http://reviews.llvm.org/D7648#123947, @ismailp wrote:
> Richard,
>
> I think this check should allow expressions originating from macros:
>
> #define HAS_XYZ_FEATURE true
> static /*constexpr*/ bool returnTrue() { return true; }
> if (returnTrue() && HAS_XYZ_FEATURE);
>
I added these test cases:
static constexpr bool truthy()
{
return true;
}
#define HAS_XYZ_FEATURE true
void macros_and_constexprs()
{
int i = 0;
bool b = (i == 0);
if (b && truthy()) {
i = 1;
}
i = 2;
if (b && HAS_XYZ_FEATURE) {
i = 3;
}
i = 4;
}
The second test case was automatically handled by the existing code:
llvm/tools/clang/tools/extra/test/clang-tidy/readability-simplify-bool-expr.cpp:297:14:
warning: Redundant boolean constant supplied to boolean operator.
[readability-simplify-boolean-expr]
if (b && HAS_XYZ_FEATURE) {
^
b
llvm/tools/clang/tools/extra/test/clang-tidy/readability-simplify-bool-expr.cpp:287:25:
note: expanded from macro 'HAS_XYZ_FEATURE'
#define HAS_XYZ_FEATURE true
^
I will look into the constexpr case.
http://reviews.llvm.org/D7648
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits