From dde5557e87e1163ad792471e0bdbb2cd17894576 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 14 Apr 2011 00:51:41 +0000 Subject: [PATCH] Re-fix r129481 and r129465 properly. Nulls fixits shouldn't be dropped in DiagnosticBuilder::AddFixItHint: they will be dropped along with any other (possibly valid) fixits later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129495 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Diagnostic.h | 3 --- lib/Sema/SemaExpr.cpp | 6 ++---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 3fc60d136b..2934632596 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -741,9 +741,6 @@ public: } void AddFixItHint(const FixItHint &Hint) const { - if (Hint.isNull()) - return; - assert(NumFixItHints < Diagnostic::MaxFixItHints && "Too many fix-it hints!"); if (DiagObj) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 8ccb9b8180..b3aaaa2e9e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10092,12 +10092,10 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) { << FixItHint::CreateReplacement(Loc, "=="); SourceLocation Open = E->getSourceRange().getBegin(); - SourceLocation Close = E->getSourceRange().getEnd(); - SourceLocation LocForEndOfToken = - Close.isMacroID() ? Close : PP.getLocForEndOfToken(Close); + SourceLocation Close = PP.getLocForEndOfToken(E->getSourceRange().getEnd()); Diag(Loc, diag::note_condition_assign_silence) << FixItHint::CreateInsertion(Open, "(") - << FixItHint::CreateInsertion(LocForEndOfToken, ")"); + << FixItHint::CreateInsertion(Close, ")"); } /// \brief Redundant parentheses over an equality comparison can indicate -- 2.40.0