On Mon, Jul 22, 2013 at 4:09 PM, Eli Friedman <[email protected]>wrote:
> Author: efriedma > Date: Mon Jul 22 18:09:39 2013 > New Revision: 186889 > > URL: http://llvm.org/viewvc/llvm-project?rev=186889&view=rev > Log: > 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. > You can use -fdiagnostics-parseable-fixits with FileCheck to test fixits on notes. > Modified: > cfe/trunk/lib/Sema/SemaExpr.cpp > > Modified: cfe/trunk/lib/Sema/SemaExpr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=186889&r1=186888&r2=186889&view=diff > > ============================================================================== > --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) > +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul 22 18:09:39 2013 > @@ -7392,6 +7392,8 @@ static void diagnoseLogicalNotOnLHSofCom > 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 diagnoseLogicalNotOnLHSofCom > 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, ")"); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
