r186889 - Don't emit open-paren fixit without close-paren.

Richard Smith richard at metafoo.co.uk
Mon Jul 22 16:14:16 PDT 2013


On Mon, Jul 22, 2013 at 4:09 PM, Eli Friedman <eli.friedman at gmail.com>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
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130722/152da75a/attachment.html>


More information about the cfe-commits mailing list