[cfe-commits] r101073 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/FixIt/fixit.c

Chris Lattner clattner at apple.com
Mon Apr 12 15:13:03 PDT 2010


On Apr 12, 2010, at 3:10 PM, Ted Kremenek wrote:

> Author: kremenek
> Date: Mon Apr 12 17:10:35 2010
> New Revision: 101073
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=101073&view=rev
> Log:
> Add fixit hint for missing ':' in ternary expressions.

Nice!  One refinement: fixit hints should recover as if they saw the expected thing.  In this case, it means that the 'return ExprError' shouldn't happen, maybe a : could be injected into the token stream?

-Chris

> 
> Modified:
>    cfe/trunk/lib/Parse/ParseExpr.cpp
>    cfe/trunk/test/FixIt/fixit.c
> 
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=101073&r1=101072&r2=101073&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Apr 12 17:10:35 2010
> @@ -336,7 +336,8 @@
>       }
> 
>       if (Tok.isNot(tok::colon)) {
> -        Diag(Tok, diag::err_expected_colon);
> +        Diag(Tok, diag::err_expected_colon)
> +          << FixItHint::CreateInsertion(Tok.getLocation(), ": ");
>         Diag(OpToken, diag::note_matching) << "?";
>         return ExprError();
>       }
> 
> Modified: cfe/trunk/test/FixIt/fixit.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.c?rev=101073&r1=101072&r2=101073&view=diff
> ==============================================================================
> --- cfe/trunk/test/FixIt/fixit.c (original)
> +++ cfe/trunk/test/FixIt/fixit.c Mon Apr 12 17:10:35 2010
> @@ -31,3 +31,8 @@
> 
> int i0 = { 17 };
> 
> +int test_cond(int y) {
> +// CHECK: int x = y ? 1 : 2;
> +  int x = y ? 1 2;
> +  return x;
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list