[cfe-commits] r104585 - in /cfe/trunk: include/clang/Parse/Action.h include/clang/Parse/Parser.h lib/Lex/Lexer.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseObjc.cpp lib/Parse/ParseStmt.cpp lib/Parse/Parser.cpp lib/Sema/CodeCompleteConsumer.cpp lib/Sema/SemaCodeComplete.cpp test/Index/complete-recovery.m
Douglas Gregor
dgregor at apple.com
Mon May 24 22:58:43 PDT 2010
Author: dgregor
Date: Tue May 25 00:58:43 2010
New Revision: 104585
URL: http://llvm.org/viewvc/llvm-project?rev=104585&view=rev
Log:
Improve code completion in failure cases in two ways:
1) Suppress diagnostics as soon as we form the code-completion
token, so we don't get any error/warning spew from the early
end-of-file.
2) If we consume a code-completion token when we weren't expecting
one, go into a code-completion recovery path that produces the best
results it can based on the context that the parser is in.
Added:
cfe/trunk/test/Index/complete-recovery.m
Modified:
cfe/trunk/include/clang/Parse/Action.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue May 25 00:58:43 2010
@@ -2649,9 +2649,13 @@
/// \brief Code completion occurs at the beginning of the
/// initialization statement (or expression) in a for loop.
CCC_ForInit,
- /// \brief Code completion ocurs within the condition of an if,
+ /// \brief Code completion occurs within the condition of an if,
/// while, switch, or for statement.
- CCC_Condition
+ CCC_Condition,
+ /// \brief Code completion occurs within the body of a function on a
+ /// recovery path, where we do not have a specific handle on our position
+ /// in the grammar.
+ CCC_RecoveryInFunction
};
/// \brief Code completion for an ordinary name that occurs within the given
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue May 25 00:58:43 2010
@@ -234,6 +234,11 @@
assert(!isTokenStringLiteral() && !isTokenParen() && !isTokenBracket() &&
!isTokenBrace() &&
"Should consume special tokens with Consume*Token");
+ if (Tok.is(tok::code_completion)) {
+ CodeCompletionRecovery();
+ return ConsumeCodeCompletionToken();
+ }
+
PrevTokLocation = Tok.getLocation();
PP.Lex(Tok);
return PrevTokLocation;
@@ -308,6 +313,22 @@
return PrevTokLocation;
}
+ /// \brief Consume the current code-completion token.
+ ///
+ /// This routine should be called to consume the code-completion token once
+ /// a code-completion action has already been invoked.
+ SourceLocation ConsumeCodeCompletionToken() {
+ assert(Tok.is(tok::code_completion));
+ PrevTokLocation = Tok.getLocation();
+ PP.Lex(Tok);
+ return PrevTokLocation;
+ }
+
+ ///\ brief When we are consuming a code-completion token within having
+ /// matched specific position in the grammar, provide code-completion results
+ /// based on context.
+ void CodeCompletionRecovery();
+
/// GetLookAheadToken - This peeks ahead N tokens and returns that token
/// without consuming any tokens. LookAhead(0) returns 'Tok', LookAhead(1)
/// returns the token after Tok, etc.
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue May 25 00:58:43 2010
@@ -1359,6 +1359,9 @@
// Only do the eof -> code_completion translation once.
PP->SetCodeCompletionPoint(0, 0, 0);
+
+ // Silence any diagnostics that occur once we hit the code-completion point.
+ PP->getDiagnostics().setSuppressAllDiagnostics(true);
return true;
}
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue May 25 00:58:43 2010
@@ -839,7 +839,7 @@
CCC = Action::CCC_ObjCImplementation;
Actions.CodeCompleteOrdinaryName(CurScope, CCC);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
DS.SetRangeStart(Tok.getLocation());
@@ -1870,7 +1870,7 @@
if (Tok.is(tok::code_completion)) {
// Code completion for an enum name.
Actions.CodeCompleteTag(CurScope, DeclSpec::TST_enum);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
llvm::OwningPtr<AttributeList> Attr;
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue May 25 00:58:43 2010
@@ -50,7 +50,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteNamespaceDecl(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
SourceLocation IdentLoc;
@@ -136,7 +136,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteNamespaceAliasDecl(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
CXXScopeSpec SS;
@@ -231,7 +231,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteUsing(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.is(tok::kw_namespace))
@@ -268,7 +268,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteUsingDirective(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
CXXScopeSpec SS;
@@ -610,7 +610,7 @@
if (Tok.is(tok::code_completion)) {
// Code completion for a struct, class, or union name.
Actions.CodeCompleteTag(CurScope, TagType);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
AttributeList *AttrList = 0;
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue May 25 00:58:43 2010
@@ -222,7 +222,7 @@
Parser::OwningExprResult Parser::ParseAssignmentExpression() {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Expression);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.is(tok::kw_throw))
@@ -906,7 +906,7 @@
return ParsePostfixExpressionSuffix(ParseBlockLiteralExpression());
case tok::code_completion:
Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Expression);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
NotCastExpr, TypeOfCast);
case tok::l_square:
@@ -975,7 +975,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteCall(CurScope, LHS.get(), 0, 0);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::r_paren)) {
@@ -1029,7 +1029,7 @@
Actions.CodeCompleteMemberReferenceExpr(CurScope, LHS.get(),
OpLoc, OpKind == tok::arrow);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (MayBePseudoDestructor) {
@@ -1562,7 +1562,7 @@
if (Tok.is(tok::code_completion)) {
if (Completer)
(Actions.*Completer)(CurScope, Data, Exprs.data(), Exprs.size());
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
OwningExprResult Expr(ParseAssignmentExpression());
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Tue May 25 00:58:43 2010
@@ -110,7 +110,7 @@
// Code completion for a nested-name-specifier, where the code
// code completion token follows the '::'.
Actions.CodeCompleteQualifiedId(CurScope, SS, EnteringContext);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
}
@@ -729,7 +729,7 @@
bool ConvertToBoolean) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Condition);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (!isCXXConditionDeclaration()) {
@@ -1274,7 +1274,7 @@
Actions.CodeCompleteOperatorName(CurScope);
// Consume the operator token.
- ConsumeToken();
+ ConsumeCodeCompletionToken();
// Don't try to parse any further.
return true;
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue May 25 00:58:43 2010
@@ -32,7 +32,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCAtDirective(CurScope, ObjCImpDecl, false);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
switch (Tok.getObjCKeywordID()) {
@@ -131,7 +131,7 @@
// Code completion after '@interface'.
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCInterfaceDecl(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -149,7 +149,7 @@
IdentifierInfo *categoryId = 0;
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCInterfaceCategory(CurScope, nameId, nameLoc);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
// For ObjC2, the category name is optional (not an error).
@@ -204,7 +204,7 @@
// Code completion of superclass names.
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCSuperclass(CurScope, nameId, nameLoc);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -350,7 +350,7 @@
Actions.CodeCompleteOrdinaryName(CurScope,
ObjCImpDecl? Action::CCC_ObjCImplementation
: Action::CCC_ObjCInterface);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
// If we don't have an @ directive, parse it as a function definition.
@@ -371,7 +371,7 @@
SourceLocation AtLoc = ConsumeToken(); // the "@"
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCAtDirective(CurScope, ObjCImpDecl, true);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
break;
}
@@ -438,7 +438,7 @@
// EOF. In the former case, eat the @end. In the later case, emit an error.
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCAtDirective(CurScope, ObjCImpDecl, true);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
} else if (Tok.isObjCAtKeyword(tok::objc_end))
ConsumeToken(); // the "end" identifier
else
@@ -477,7 +477,7 @@
while (1) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCPropertyFlags(CurScope, DS);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
const IdentifierInfo *II = Tok.getIdentifierInfo();
@@ -514,7 +514,7 @@
else
Actions.CodeCompleteObjCPropertyGetter(CurScope, ClassDecl,
Methods, NumMethods);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -782,7 +782,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCMethodDecl(CurScope, mType == tok::minus,
/*ReturnType=*/0, IDecl);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
// Parse the return type if present.
@@ -799,7 +799,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCMethodDecl(CurScope, mType == tok::minus,
ReturnType, IDecl);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
// Now parse the selector.
@@ -945,7 +945,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCProtocolReferences(ProtocolIdents.data(),
ProtocolIdents.size());
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -1026,7 +1026,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCAtVisibility(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
switch (Tok.getObjCKeywordID()) {
@@ -1046,7 +1046,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteOrdinaryName(CurScope,
Action::CCC_ObjCInstanceVariableList);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
struct ObjCIvarCallback : FieldCallback {
@@ -1117,7 +1117,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCProtocolDecl(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -1203,7 +1203,7 @@
// Code completion after '@implementation'.
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCImplementationDecl(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -1222,7 +1222,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCImplementationCategory(CurScope, nameId, nameLoc);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.is(tok::identifier)) {
@@ -1342,7 +1342,7 @@
while (true) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCPropertyDefinition(CurScope, ObjCImpDecl);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -1361,7 +1361,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCPropertySynthesizeIvar(CurScope, propertyId,
ObjCImpDecl);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -1400,7 +1400,7 @@
while (true) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCPropertyDefinition(CurScope, ObjCImpDecl);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
if (Tok.isNot(tok::identifier)) {
@@ -1654,7 +1654,7 @@
Parser::OwningStmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCAtStatement(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
return StmtError();
}
@@ -1685,7 +1685,7 @@
switch (Tok.getKind()) {
case tok::code_completion:
Actions.CodeCompleteObjCAtExpression(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
return ExprError();
case tok::string_literal: // primary-expression: string-literal
@@ -1925,7 +1925,7 @@
else
Actions.CodeCompleteObjCInstanceMessage(CurScope, ReceiverExpr.get(),
0, 0);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
// Parse objc-selector
@@ -1979,7 +1979,7 @@
Actions.CodeCompleteObjCInstanceMessage(CurScope, ReceiverExpr.get(),
KeyIdents.data(),
KeyIdents.size());
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
// Check for another keyword selector.
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Tue May 25 00:58:43 2010
@@ -283,7 +283,7 @@
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteCase(CurScope);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
/// We don't want to treat 'case x : y' as a potential typo for 'case x::y'.
@@ -1000,7 +1000,7 @@
Actions.CodeCompleteOrdinaryName(CurScope,
C99orCXXorObjC? Action::CCC_ForInit
: Action::CCC_Expression);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
}
// Parse the first part of the for specifier.
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Tue May 25 00:58:43 2010
@@ -134,7 +134,7 @@
/// returned.
bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID,
const char *Msg, tok::TokenKind SkipToTok) {
- if (Tok.is(ExpectedTok)) {
+ if (Tok.is(ExpectedTok) || Tok.is(tok::code_completion)) {
ConsumeAnyToken();
return false;
}
@@ -189,7 +189,11 @@
case tok::eof:
// Ran out of tokens.
return false;
-
+
+ case tok::code_completion:
+ ConsumeToken();
+ return false;
+
case tok::l_paren:
// Recursively skip properly-nested parens.
ConsumeParen();
@@ -447,7 +451,7 @@
Actions.CodeCompleteOrdinaryName(CurScope,
ObjCImpDecl? Action::CCC_ObjCImplementation
: Action::CCC_Namespace);
- ConsumeToken();
+ ConsumeCodeCompletionToken();
return ParseExternalDeclaration(Attr);
case tok::kw_using:
case tok::kw_namespace:
@@ -1072,6 +1076,22 @@
return false;
}
+void Parser::CodeCompletionRecovery() {
+ for (Scope *S = CurScope; S; S = S->getParent()) {
+ if (S->getFlags() & Scope::FnScope) {
+ Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_RecoveryInFunction);
+ return;
+ }
+
+ if (S->getFlags() & Scope::ClassScope) {
+ Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Class);
+ return;
+ }
+ }
+
+ Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Namespace);
+}
+
// Anchor the Parser::FieldCallback vtable to this translation unit.
// We use a spurious method instead of the destructor because
// destroying FieldCallbacks can actually be slightly
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Tue May 25 00:58:43 2010
@@ -459,11 +459,6 @@
}
}
}
-
- // Once we've printed the code-completion results, suppress remaining
- // diagnostics.
- // FIXME: Move this somewhere else!
- SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics();
}
void
@@ -478,11 +473,6 @@
delete CCS;
}
}
-
- // Once we've printed the code-completion results, suppress remaining
- // diagnostics.
- // FIXME: Move this somewhere else!
- SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics();
}
void
@@ -599,11 +589,6 @@
CCS->Serialize(OS);
delete CCS;
}
-
- // Once we've printed the code-completion results, suppress remaining
- // diagnostics.
- // FIXME: Move this somewhere else!
- SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics();
}
void
@@ -619,9 +604,4 @@
CCS->Serialize(OS);
delete CCS;
}
-
- // Once we've printed the code-completion results, suppress remaining
- // diagnostics.
- // FIXME: Move this somewhere else!
- SemaRef.PP.getDiagnostics().setSuppressAllDiagnostics();
}
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=104585&r1=104584&r2=104585&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue May 25 00:58:43 2010
@@ -843,6 +843,7 @@
case Action::CCC_Statement:
case Action::CCC_ForInit:
case Action::CCC_Condition:
+ case Action::CCC_RecoveryInFunction:
break;
}
}
@@ -994,6 +995,7 @@
AddObjCVisibilityResults(SemaRef.getLangOptions(), Results, true);
break;
+ case Action::CCC_RecoveryInFunction:
case Action::CCC_Statement: {
Results.AddResult(Result("typedef"));
@@ -1925,6 +1927,10 @@
case CCC_Condition:
Results.setFilter(&ResultBuilder::IsOrdinaryName);
break;
+
+ case CCC_RecoveryInFunction:
+ // Unfiltered
+ break;
}
CodeCompletionDeclConsumer Consumer(Results, CurContext);
@@ -3079,8 +3085,6 @@
}
Results.ExitScope();
-
- // This also suppresses remaining diagnostics.
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
}
Added: cfe/trunk/test/Index/complete-recovery.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-recovery.m?rev=104585&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-recovery.m (added)
+++ cfe/trunk/test/Index/complete-recovery.m Tue May 25 00:58:43 2010
@@ -0,0 +1,21 @@
+/* Run lines are at the end, since line/column matter in this test. */
+
+ at interface A
+- (void)method:(int)x;
+ at end
+
+ at implementation A
+- (void)method:(int)x {
+ A *a = [A method:1];
+ blarg * blah = wibble
+}
+ at end
+
+// RUN: c-index-test -code-completion-at=%s:9:20 %s 2>%t | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: not grep error %t
+// CHECK-CC1: NotImplemented:{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC1: NotImplemented:{TypedText _Bool}
+// CHECK-CC1: VarDecl:{ResultType A *}{TypedText a}
+// CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
+
+// RUN: c-index-test -code-completion-at=%s:10:24 %s 2>%t | FileCheck -check-prefix=CHECK-CC1 %s
More information about the cfe-commits
mailing list