[PATCH] D65192: [Sema] Disable some enabled-by-default -Wparentheses diagnostics

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 19:30:54 PDT 2019

MaskRay marked 3 inline comments as done.
MaskRay added inline comments.

Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5647-5650
 def warn_overloaded_shift_in_comparison :Warning<
   "overloaded operator %select{>>|<<}0 has higher precedence than "
   "comparison operator">,
+  InGroup<OverloadedShiftOpParentheses>, DefaultIgnore;
rsmith wrote:
> I think this should remain enabled by default unless you have evidence of false positives. In my experience, this catches bugs like
> ```
> ostream << "got expected result: " << x == 0;
> ```
> ... and very little else.
> That said, perhaps we could do better here, since this warning is typically followed by an error: if we detect the special case of overload resolution failure for an operator with an `<<` (or `>>`) operator expression on its left-hand side, we could produce a much more targeted diagnostic for this case and avoid the current situation of a warning followed by an error for the same problem. If we did that, we could probably remove this warning entirely.
Restored this one.

Searching for Wno-parentheses can probably give more interesting results...

  rC Clang



More information about the cfe-commits mailing list