Commit Graph

5 Commits

Author SHA1 Message Date
Nico Weber 44f6f2ee42 Expand -Wlogical-not-parentheses to also fire on `!x & A`.
This is a misspelling of the intended !(x & A) negated bit test that happens in
practice every now and then.

I ran this on Chromium and all its dependencies, and it fired 0 times -- no
false or true positives, but it would've caught a bug in an in-progress change
that had to be caught by a Visual Studio warning instead.

https://reviews.llvm.org/D26035

llvm-svn: 285310
2016-10-27 16:32:06 +00:00
Richard Trieu 1bab6e5034 Make a test less brittle.
Capture line numbers in a variable for FileCheck instead of hardcoding them.

llvm-svn: 245250
2015-08-17 22:18:30 +00:00
Eli Friedman d1eec9cc96 Testcase for PR16673.
llvm-svn: 186891
2013-07-22 23:30:13 +00:00
Richard Trieu 949abc327d Improve -Wlogical-not-parentheses to catch when the not is applied to an enum.
llvm-svn: 185602
2013-07-04 00:50:18 +00:00
Richard Trieu bb4b894e0b Add a new warning, -Wlogical-not-parentheses, to -Wparentheses.
This warning triggers on the logical not of a non-boolean expression on the
left hand side of comparison.  Often, the user meant to negate the comparison,
not just the left hand side of the comparison.  Two notes are also emitted,
the first with a fix-it to add parentheses around the comparison, and the other
to put parenthesis around the not expression to silence the warning.

bool not_equal(int x, int y) {
  return !x == y;  // warn here
}

  return !(x == y);  // first fix-it, to negate comparison.

  return (!x) == y;  // second fix-it, to silence warning.

llvm-svn: 183688
2013-06-10 18:52:07 +00:00