From: Eli Friedman Date: Mon, 22 Jul 2013 23:09:39 +0000 (+0000) Subject: Don't emit open-paren fixit without close-paren. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef0b4a36f207bb02d6a35847cfd9633aacc3f414;p=platform%2Fupstream%2Fllvm.git Don't emit open-paren fixit without close-paren. getLocForEndOfToken() isn't guaranteed to succeed; if it doesn't, make sure we do something sane. Fixes PR16673. I'm not sure how to write a testcase for this short of grepping through the diagnostic output. llvm-svn: 186889 --- diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 2c93314..16b5e3c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7392,6 +7392,8 @@ static void diagnoseLogicalNotOnLHSofComparison(Sema &S, ExprResult &LHS, SourceLocation FirstOpen = SubExpr->getLocStart(); SourceLocation FirstClose = RHS.get()->getLocEnd(); FirstClose = S.getPreprocessor().getLocForEndOfToken(FirstClose); + if (FirstClose.isInvalid()) + FirstOpen = SourceLocation(); S.Diag(UO->getOperatorLoc(), diag::note_logical_not_fix) << FixItHint::CreateInsertion(FirstOpen, "(") << FixItHint::CreateInsertion(FirstClose, ")"); @@ -7400,6 +7402,8 @@ static void diagnoseLogicalNotOnLHSofComparison(Sema &S, ExprResult &LHS, SourceLocation SecondOpen = LHS.get()->getLocStart(); SourceLocation SecondClose = LHS.get()->getLocEnd(); SecondClose = S.getPreprocessor().getLocForEndOfToken(SecondClose); + if (SecondClose.isInvalid()) + SecondOpen = SourceLocation(); S.Diag(UO->getOperatorLoc(), diag::note_logical_not_silence_with_parens) << FixItHint::CreateInsertion(SecondOpen, "(") << FixItHint::CreateInsertion(SecondClose, ")");