[PATCH] D63082: [Diagnostics] Added support for -Wint-in-bool-context
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 17 12:47:57 PDT 2019
aaron.ballman added inline comments.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5609
+def warn_mul_in_bool_context : Warning<
+ "'*' in bool context, maybe you mean '&&'?">,
+ InGroup<IntInBoolContext>;
----------------
I would appreciate seeing some motivating examples for this case, because it seems like the `&&` suggestion is misleading more often than it's helpful in the current test cases.
Also, what is a "bool context"?
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5625
+ "evaluate to 'true'">,
+ InGroup<IntInBoolContext>;
+
----------------
This one seems like it should be in the `TautologicalConstantCompare` group, no?
================
Comment at: lib/Sema/SemaChecking.cpp:11099
+static void DiagnoseIntInBoolContext(Sema &S, Expr *E) {
+ E = E->IgnoreParenImpCasts();
----------------
`const Expr *E`?
================
Comment at: test/Sema/integer-overflow.c:37
// expected-warning at +1 2{{overflow in expression; result is 536870912 with type 'int'}}
- overflow = 4608 * 1024 * 1024 ? 4608 * 1024 * 1024 : 0;
+ overflow = 4608 * 1024 * 1024 ? 4608 * 1024 * 1024 : 0; // expected-warning {{'*' in bool context, maybe you mean '&&'?}}
----------------
I don't think the new diagnostic adds a lot of value here, though GCC does warn on it similarly. Truthfully, the same goes for the other test cases in this file.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63082/new/
https://reviews.llvm.org/D63082
More information about the cfe-commits
mailing list