[PATCH] D58878: [Diagnostics] Warn for assignments in bool contexts
Dávid Bolvanský via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 9 05:05:29 PST 2019
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6738
+ "assignment to bool">,
+ InGroup<AssigmentInBoolContext>;
// Completely identical except off by default.
----------------
rjmccall wrote:
> 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.
This is quite problematic to isolate this one since tha patch add DiagnoseAssignmentAsCondition call into the PerformImplicitConversion so I don't know how to see in PerformImplicitConversion whether we are in the condition or not. So, this new warning note wins over current one "using the result of an assignment as a condition without parentheses" always :/
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58878/new/
https://reviews.llvm.org/D58878
More information about the cfe-commits
mailing list