[cfe-commits] r61651 - /cfe/trunk/lib/Parse/ParseTentative.cpp

Chris Lattner sabre at nondot.org
Sun Jan 4 15:33:57 PST 2009


Author: lattner
Date: Sun Jan  4 17:33:56 2009
New Revision: 61651

URL: http://llvm.org/viewvc/llvm-project?rev=61651&view=rev
Log:
push the call in isCXXDeclarationSpecifier to TryAnnotateTypeOrScopeToken 
down into the two cases that it can possibly affect.  This avoids calls
to it that obviously can't do anything.


Modified:
    cfe/trunk/lib/Parse/ParseTentative.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=61651&r1=61650&r2=61651&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Sun Jan  4 17:33:56 2009
@@ -558,10 +558,27 @@
 /// [GNU]     restrict
 ///
 Parser::TPResult Parser::isCXXDeclarationSpecifier() {
-  // Annotate typenames and C++ scope specifiers.
-  TryAnnotateTypeOrScopeToken();
-
   switch (Tok.getKind()) {
+  case tok::identifier:   // foo::bar
+    // Annotate typenames and C++ scope specifiers.  If we get one, just
+    // recurse to handle whatever we get.
+    if (TryAnnotateTypeOrScopeToken())
+      return isCXXDeclarationSpecifier();
+    // Otherwise, not a typename.
+    return TPResult::False();
+
+  case tok::coloncolon:   // ::foo::bar
+      if (NextToken().is(tok::kw_new) ||    // ::new
+          NextToken().is(tok::kw_delete))   // ::delete
+        return TPResult::False();
+      
+    // Annotate typenames and C++ scope specifiers.  If we get one, just
+    // recurse to handle whatever we get.
+    if (TryAnnotateTypeOrScopeToken())
+      return isCXXDeclarationSpecifier();
+    // Otherwise, not a typename.
+    return TPResult::False();
+      
     // decl-specifier:
     //   storage-class-specifier
     //   type-specifier





More information about the cfe-commits mailing list