r207823 - Cut off parsing early during code completion

Alp Toker alp at nuanti.com
Thu May 1 20:43:15 PDT 2014


Author: alp
Date: Thu May  1 22:43:14 2014
New Revision: 207823

URL: http://llvm.org/viewvc/llvm-project?rev=207823&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseExprCXX.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=207823&r1=207822&r2=207823&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu May  1 22:43:14 2014
@@ -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();

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=207823&r1=207822&r2=207823&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu May  1 22:43:14 2014
@@ -767,7 +767,7 @@ Optional<unsigned> Parser::ParseLambdaIn
               !Intro.Captures.empty())) {
           Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, 
                                                /*AfterAmpersand=*/false);
-          ConsumeCodeCompletionToken();
+          cutOffParsing();
           break;
         }
 
@@ -784,7 +784,7 @@ Optional<unsigned> Parser::ParseLambdaIn
       else
         Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, 
                                              /*AfterAmpersand=*/false);
-      ConsumeCodeCompletionToken();
+      cutOffParsing();
       break;
     }
 
@@ -808,7 +808,7 @@ Optional<unsigned> Parser::ParseLambdaIn
         if (Tok.is(tok::code_completion)) {
           Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, 
                                                /*AfterAmpersand=*/true);
-          ConsumeCodeCompletionToken();
+          cutOffParsing();
           break;
         }
       }

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=207823&r1=207822&r2=207823&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Thu May  1 22:43:14 2014
@@ -1896,8 +1896,7 @@ Parser::DeclGroupPtrTy Parser::ParseModu
     if (!Tok.is(tok::identifier)) {
       if (Tok.is(tok::code_completion)) {
         Actions.CodeCompleteModuleImport(ImportLoc, Path);
-        ConsumeCodeCompletionToken();
-        SkipUntil(tok::semi);
+        cutOffParsing();
         return DeclGroupPtrTy();
       }
       





More information about the cfe-commits mailing list