[PATCH] D58878: [Diagnostics] Warn for assignments in bool contexts

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 7 17:53:30 PST 2019


rjmccall added inline comments.


================
Comment at: include/clang/Basic/DiagnosticGroups.td:699
 def ParenthesesOnEquality : DiagGroup<"parentheses-equality">;
+def AssigmentInBoolContext : DiagGroup<"assigment-in-bool-context">;
 def Parentheses : DiagGroup<"parentheses",
----------------
"assignment", in both places


================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6738
+  "assignment to bool">,
+  InGroup<AssigmentInBoolContext>;
 // Completely identical except off by default.
----------------
Sorry, I didn't mean to suggest that you should change the existing diagnostic.  You should add a second diagnostic in a new warning group (which should be implied by `-Wparentheses`) that you use just in this case.

We try to add new warnings this way — even when they're just generalizations of existing warnings — so that they can be independently disabled by e.g. the compiler teams at Apple and Google that need to periodically roll out new compilers across a large codebase.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58878/new/

https://reviews.llvm.org/D58878





More information about the cfe-commits mailing list