]> granicus.if.org Git - clang/commitdiff
Improve fixit for comparison operator on lhs of bitwise operator.
authorNico Weber <nicolasweber@gmx.de>
Sun, 3 Jun 2012 07:07:00 +0000 (07:07 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sun, 3 Jun 2012 07:07:00 +0000 (07:07 +0000)
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

lib/Sema/SemaExpr.cpp
test/Misc/tabstop.c

index 17260c29c943ef5b90c587bd62842aa3618fd3f2..362bafaa408d927914b5c9384aa959853cd5d0a2 100644 (file)
@@ -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);
index 49c4d7bebbbaea75f03f8d63bcfed18b1e3068c5..7f59b6ab32b1d0734117ad26f6789125cb545980 100644 (file)
@@ -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: {{^     }}    (     )