From: Fariborz Jahanian Date: Wed, 13 Apr 2011 22:18:37 +0000 (+0000) Subject: Issue the 2nd fixit even if fix-it hint is supressed. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6027461b6c4d1567a8d7533ad97ccf81bd2b9500;p=clang Issue the 2nd fixit even if fix-it hint is supressed. // rdar://9091893 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129481 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 3d2b14933e..ac1128b361 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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 diff --git a/test/FixIt/no-macro-fixit.c b/test/FixIt/no-macro-fixit.c index 3685ab1087..b6a9285e22 100644 --- a/test/FixIt/no-macro-fixit.c +++ b/test/FixIt/no-macro-fixit.c @@ -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}} } }