]> granicus.if.org Git - clang/commitdiff
Issue the 2nd fixit even if fix-it hint is supressed.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 13 Apr 2011 22:18:37 +0000 (22:18 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 13 Apr 2011 22:18:37 +0000 (22:18 +0000)
// rdar://9091893

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129481 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/FixIt/no-macro-fixit.c

index 3d2b14933e2734e1c91e12ad2f15c5c1547d57e7..ac1128b361dc860a813177dc33a8e9c74f67365f 100644 (file)
@@ -10081,12 +10081,11 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
 
   SourceLocation Open = E->getSourceRange().getBegin();
   SourceLocation Close = E->getSourceRange().getEnd();
-  if (!Open.isMacroID() && !Close.isMacroID()) {
-    SourceLocation LocForEndOfToken = PP.getLocForEndOfToken(Close);
-    Diag(Loc, diag::note_condition_assign_silence)
-      << FixItHint::CreateInsertion(Open, "(")
-      << FixItHint::CreateInsertion(LocForEndOfToken, ")");
-  }
+  SourceLocation LocForEndOfToken = 
+    Close.isMacroID() ? Close : PP.getLocForEndOfToken(Close);
+  Diag(Loc, diag::note_condition_assign_silence)
+        << FixItHint::CreateInsertion(Open, "(")
+        << FixItHint::CreateInsertion(LocForEndOfToken, ")");
 }
 
 /// \brief Redundant parentheses over an equality comparison can indicate
index 3685ab10877de952a782ef3ee2b294d13c5bf6a4..b6a9285e22f083e9b5ae36cf4b4f94af95a7c5d8 100644 (file)
@@ -10,6 +10,7 @@ void myFunc() {
     int value;
 
     while (value = va_arg(values, int)) {  // expected-warning {{using the result of an assignment as a condition without parentheses}} \
-                                           // expected-note {{use '==' to turn this assignment into an equality comparison}}
+                                           // expected-note {{use '==' to turn this assignment into an equality comparison}} \
+                                          // expected-note {{place parentheses around the assignment to silence this warning}}
     }
 }