diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 5c72b91bde11..1c6c5bd0bb86 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -419,8 +419,9 @@ private: /// \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. + /// This routine can be called to consume the code-completion token and + /// continue processing in special cases where \c cutOffParsing() isn't + /// desired, such as token caching or completion with lookahead. SourceLocation ConsumeCodeCompletionToken() { assert(Tok.is(tok::code_completion)); PrevTokLocation = Tok.getLocation(); diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 614949c93510..7d9fa1482d39 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -767,7 +767,7 @@ Optional Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, !Intro.Captures.empty())) { Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, /*AfterAmpersand=*/false); - ConsumeCodeCompletionToken(); + cutOffParsing(); break; } @@ -784,7 +784,7 @@ Optional Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, else Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, /*AfterAmpersand=*/false); - ConsumeCodeCompletionToken(); + cutOffParsing(); break; } @@ -808,7 +808,7 @@ Optional Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, if (Tok.is(tok::code_completion)) { Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, /*AfterAmpersand=*/true); - ConsumeCodeCompletionToken(); + cutOffParsing(); break; } } diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 9d3f251a55a6..b096f1c0cb77 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1896,8 +1896,7 @@ Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) { if (!Tok.is(tok::identifier)) { if (Tok.is(tok::code_completion)) { Actions.CodeCompleteModuleImport(ImportLoc, Path); - ConsumeCodeCompletionToken(); - SkipUntil(tok::semi); + cutOffParsing(); return DeclGroupPtrTy(); }