Cut off parsing early during code completion

These calls to ConsumeCodeCompletionToken() caused parsing to continue
needlessly when an immediate cutOffParsing() would do.

Document the function to clarify its correct usage.

llvm-svn: 207823
This commit is contained in:
Alp Toker 2014-05-02 03:43:14 +00:00
parent b6d4e8cd4e
commit 1c583cc668
3 changed files with 7 additions and 7 deletions

View File

@ -419,8 +419,9 @@ private:
/// \brief Consume the current code-completion token. /// \brief Consume the current code-completion token.
/// ///
/// This routine should be called to consume the code-completion token once /// This routine can be called to consume the code-completion token and
/// a code-completion action has already been invoked. /// continue processing in special cases where \c cutOffParsing() isn't
/// desired, such as token caching or completion with lookahead.
SourceLocation ConsumeCodeCompletionToken() { SourceLocation ConsumeCodeCompletionToken() {
assert(Tok.is(tok::code_completion)); assert(Tok.is(tok::code_completion));
PrevTokLocation = Tok.getLocation(); PrevTokLocation = Tok.getLocation();

View File

@ -767,7 +767,7 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
!Intro.Captures.empty())) { !Intro.Captures.empty())) {
Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro,
/*AfterAmpersand=*/false); /*AfterAmpersand=*/false);
ConsumeCodeCompletionToken(); cutOffParsing();
break; break;
} }
@ -784,7 +784,7 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
else else
Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro,
/*AfterAmpersand=*/false); /*AfterAmpersand=*/false);
ConsumeCodeCompletionToken(); cutOffParsing();
break; break;
} }
@ -808,7 +808,7 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
if (Tok.is(tok::code_completion)) { if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro,
/*AfterAmpersand=*/true); /*AfterAmpersand=*/true);
ConsumeCodeCompletionToken(); cutOffParsing();
break; break;
} }
} }

View File

@ -1896,8 +1896,7 @@ Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) {
if (!Tok.is(tok::identifier)) { if (!Tok.is(tok::identifier)) {
if (Tok.is(tok::code_completion)) { if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteModuleImport(ImportLoc, Path); Actions.CodeCompleteModuleImport(ImportLoc, Path);
ConsumeCodeCompletionToken(); cutOffParsing();
SkipUntil(tok::semi);
return DeclGroupPtrTy(); return DeclGroupPtrTy();
} }