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>.
llvm-svn: 105175
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 7be1a19..8fb71c3 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -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();