[cfe-commits] r74259 - /cfe/trunk/lib/Parse/ParseExprCXX.cpp

Chris Lattner sabre at nondot.org
Thu Jun 25 20:45:58 PDT 2009


Author: lattner
Date: Thu Jun 25 22:45:46 2009
New Revision: 74259

URL: http://llvm.org/viewvc/llvm-project?rev=74259&view=rev
Log:
simplify some code.

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

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu Jun 25 22:45:46 2009
@@ -84,41 +84,41 @@
       continue;
     }
 
+    
+    // Parse the optional 'template' keyword, then make sure we have
+    // 'identifier <' after it.
+    if (Tok.is(tok::kw_template)) {
+      SourceLocation TemplateKWLoc = ConsumeToken();
+      
+      if (Tok.isNot(tok::identifier)) {
+        Diag(Tok.getLocation(), 
+             diag::err_id_after_template_in_nested_name_spec)
+        << SourceRange(TemplateKWLoc);
+        break;
+      }
+      
+      if (NextToken().isNot(tok::less)) {
+        Diag(NextToken().getLocation(),
+             diag::err_less_after_template_name_in_nested_name_spec)
+        << Tok.getIdentifierInfo()->getName()
+        << SourceRange(TemplateKWLoc, Tok.getLocation());
+        break;
+      }
+      
+      TemplateTy Template 
+      = Actions.ActOnDependentTemplateName(TemplateKWLoc,
+                                           *Tok.getIdentifierInfo(),
+                                           Tok.getLocation(),
+                                           SS);
+      AnnotateTemplateIdToken(Template, TNK_Dependent_template_name,
+                              &SS, TemplateKWLoc, false);
+      continue;
+    }
+    
     // nested-name-specifier:
     //   type-name '::'
     //   nested-name-specifier 'template'[opt] simple-template-id '::'
-    if ((Tok.is(tok::identifier) && NextToken().is(tok::less)) ||
-        Tok.is(tok::kw_template)) {
-      // Parse the optional 'template' keyword, then make sure we have
-      // 'identifier <' after it.
-      if (Tok.is(tok::kw_template)) {
-        SourceLocation TemplateKWLoc = ConsumeToken();
-        
-        if (Tok.isNot(tok::identifier)) {
-          Diag(Tok.getLocation(), 
-               diag::err_id_after_template_in_nested_name_spec)
-            << SourceRange(TemplateKWLoc);
-          break;
-        }
-
-        if (NextToken().isNot(tok::less)) {
-          Diag(NextToken().getLocation(),
-               diag::err_less_after_template_name_in_nested_name_spec)
-            << Tok.getIdentifierInfo()->getName()
-            << SourceRange(TemplateKWLoc, Tok.getLocation());
-          break;
-        }
-
-        TemplateTy Template 
-          = Actions.ActOnDependentTemplateName(TemplateKWLoc,
-                                               *Tok.getIdentifierInfo(),
-                                               Tok.getLocation(),
-                                               SS);
-        AnnotateTemplateIdToken(Template, TNK_Dependent_template_name,
-                                &SS, TemplateKWLoc, false);
-        continue;
-      }
-
+    if (Tok.is(tok::identifier) && NextToken().is(tok::less)) {
       TemplateTy Template;
       TemplateNameKind TNK = Actions.isTemplateName(*Tok.getIdentifierInfo(),
                                                     CurScope, Template, &SS);
@@ -172,8 +172,9 @@
           SS.setScopeRep(0);
         SS.setEndLoc(CCLoc);
         continue;
-      } else
-        assert(false && "FIXME: Only type template names supported here");
+      }
+      
+      assert(false && "FIXME: Only type template names supported here");
     }
 
     // We don't have any tokens that form the beginning of a





More information about the cfe-commits mailing list