diff options
author | Nico Weber <nicolasweber@gmx.de> | 2012-06-03 07:07:00 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2012-06-03 07:07:00 +0000 |
commit | 40e29999daa20646decd3fe4aeb88a487874049c (patch) | |
tree | e63c3963840597dafd3b1c2e2e209f7e25479842 | |
parent | 2f316dd47b851fcf58c8f1f072bf390ec09bed7a (diff) |
Improve fixit for comparison operator on lhs of bitwise operator.
Before:
test.cc:2:18: note: place parentheses around the == expression to silence this warning
if (0 == flags & 0xdd)
^
( )
Now:
test.cc:2:18: note: place parentheses around the == expression to silence this warning
if (0 == flags & 0xdd)
^
( )
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157897 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | test/Misc/tabstop.c | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 17260c29c9..362bafaa40 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -8092,7 +8092,7 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, << DiagRange << BinOp::getOpcodeStr(Opc) << OpStr; SuggestParentheses(Self, OpLoc, Self.PDiag(diag::note_precedence_bitwise_silence) << OpStr, - RHSExpr->getSourceRange()); + (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange()); SuggestParentheses(Self, OpLoc, Self.PDiag(diag::note_precedence_bitwise_first) << BinOp::getOpcodeStr(Opc), ParensRange); diff --git a/test/Misc/tabstop.c b/test/Misc/tabstop.c index 49c4d7bebb..7f59b6ab32 100644 --- a/test/Misc/tabstop.c +++ b/test/Misc/tabstop.c @@ -35,13 +35,22 @@ void f(void) { if (0 & 1 == 1) {} + + if (1 == 0 & 1) + {} } // CHECK-3: {{^ }}if (0 & 1 == 1) // CHECK-3: {{^ }} ( ) +// CHECK-3: {{^ }}if (1 == 0 & 1) +// CHECK-3: {{^ }} ( ) // CHECK-4: {{^ }}if (0 & 1 == 1) // CHECK-4: {{^ }} ( ) +// CHECK-4: {{^ }}if (1 == 0 & 1) +// CHECK-4: {{^ }} ( ) // CHECK-5: {{^ }}if (0 & 1 == 1) // CHECK-5: {{^ }} ( ) +// CHECK-5: {{^ }}if (1 == 0 & 1) +// CHECK-5: {{^ }} ( ) |