[cfe-commits] r105175 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/Index/complete-exprs.c

Douglas Gregor dgregor at apple.com
Sun May 30 15:23:08 PDT 2010


Author: dgregor
Date: Sun May 30 17:23:08 2010
New Revision: 105175

URL: http://llvm.org/viewvc/llvm-project?rev=105175&view=rev
Log:
Improve parser recovery when we try to parse a call expression but the
called function itself is invalid (e.g., because of a semantic error
referring to that declaration). Fixes <rdar://problem/8044142>.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Index/complete-exprs.c

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=105175&r1=105174&r2=105175&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun May 30 17:23:08 2010
@@ -580,7 +580,8 @@
     
       Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
                                  TypeOfCast, CastTy, RParenLoc);
-      if (Res.isInvalid()) return move(Res);
+      if (Res.isInvalid()) 
+        return move(Res);
     }
 
     switch (ParenExprType) {
@@ -672,6 +673,7 @@
     Name.setIdentifier(&II, ILoc);
     Res = Actions.ActOnIdExpression(CurScope, ScopeSpec, Name, 
                                     Tok.is(tok::l_paren), false);
+
     // These can be followed by postfix-expr pieces.
     return ParsePostfixExpressionSuffix(move(Res));
   }
@@ -981,6 +983,11 @@
 
       Loc = ConsumeParen();
 
+      if (LHS.isInvalid()) {
+        SkipUntil(tok::r_paren);
+        return ExprError();
+      }
+
       if (Tok.is(tok::code_completion)) {
         Actions.CodeCompleteCall(CurScope, LHS.get(), 0, 0);
         ConsumeCodeCompletionToken();

Modified: cfe/trunk/test/Index/complete-exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-exprs.c?rev=105175&r1=105174&r2=105175&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-exprs.c (original)
+++ cfe/trunk/test/Index/complete-exprs.c Sun May 30 17:23:08 2010
@@ -7,6 +7,9 @@
   return i | j | k & l;
 }
 
+struct X f1 = { 17 };
+void f2() { f1(17); }
+
 // RUN: c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12)
@@ -28,3 +31,7 @@
 // CHECK-CC2: NotImplemented:{TypedText float} (40)
 // CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (8)
 // CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30)
+// RUN: c-index-test -code-completion-at=%s:11:16 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50)
+





More information about the cfe-commits mailing list