[cfe-commits] r61662 - in /cfe/trunk/lib/Parse: ParseExpr.cpp ParseExprCXX.cpp ParseTemplate.cpp Parser.cpp

Chris Lattner sabre at nondot.org
Sun Jan 4 17:24:06 PST 2009


Author: lattner
Date: Sun Jan  4 19:24:05 2009
New Revision: 61662

URL: http://llvm.org/viewvc/llvm-project?rev=61662&view=rev
Log:
TryAnnotateTypeOrScopeToken and TryAnnotateCXXScopeToken can 
only be called when they might be needed now, so make them assert
that their current token is :: or identifier.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Parse/ParseExprCXX.cpp
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/lib/Parse/Parser.cpp

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun Jan  4 19:24:05 2009
@@ -637,7 +637,8 @@
       return ParseCXXDeleteExpression(true, ColonColonTok.getLocation());
     // Turn the qualified name into a annot_qualtypename or annot_cxxscope if
     // it would be valid.
-    if (TryAnnotateTypeOrScopeToken(&ColonColonTok)) {
+    if ((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&
+        TryAnnotateTypeOrScopeToken(&ColonColonTok)) {
       // If so, retry (tail recurse).
       return ParseCastExpression(isUnaryExpression);
     }

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Sun Jan  4 19:24:05 2009
@@ -35,7 +35,7 @@
 bool Parser::MaybeParseCXXScopeSpecifier(CXXScopeSpec &SS,
                                          const Token *GlobalQualifier) {
   assert(getLang().CPlusPlus &&
-         "Call sites of this function should be guarded by checking for C++.");
+         "Call sites of this function should be guarded by checking for C++");
 
   if (Tok.is(tok::annot_cxxscope)) {
     assert(GlobalQualifier == 0 &&
@@ -183,13 +183,13 @@
 
   case tok::kw_operator: {
     SourceLocation OperatorLoc = Tok.getLocation();
-    if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) {
+    if (OverloadedOperatorKind Op = TryParseOperatorFunctionId())
       return Owned(Actions.ActOnCXXOperatorFunctionIdExpr(
                          CurScope, OperatorLoc, Op, Tok.is(tok::l_paren), SS));
-    } else if (TypeTy *Type = ParseConversionFunctionId()) {
-      return Owned(Actions.ActOnCXXConversionFunctionExpr(
-                         CurScope, OperatorLoc, Type, Tok.is(tok::l_paren),SS));
-    }
+    if (TypeTy *Type = ParseConversionFunctionId())
+      return Owned(Actions.ActOnCXXConversionFunctionExpr(CurScope, OperatorLoc,
+                                                          Type,
+                                                     Tok.is(tok::l_paren), SS));
 
     // We already complained about a bad conversion-function-id,
     // above.

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Sun Jan  4 19:24:05 2009
@@ -318,7 +318,7 @@
   // Parse this as a typename.
   Declarator ParamDecl(DS, Declarator::TemplateParamContext);
   ParseDeclarator(ParamDecl);
-  if(DS.getTypeSpecType() == DeclSpec::TST_unspecified && !DS.getTypeRep()) {
+  if (DS.getTypeSpecType() == DeclSpec::TST_unspecified && !DS.getTypeRep()) {
     // This probably shouldn't happen - and it's more of a Sema thing, but
     // basically we didn't parse the type name because we couldn't associate
     // it with an AST node. we should just skip to the comma or greater.
@@ -335,7 +335,7 @@
   // Is there a default value? Parsing this can be fairly annoying because
   // we have to stop on the first non-nested (paren'd) '>' as the closure
   // for the template parameter list. Or a ','.
-  if(Tok.is(tok::equal)) {
+  if (Tok.is(tok::equal)) {
     // TODO: Implement default non-type values.
     SkipUntil(tok::comma, tok::greater, true, true);
   }

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

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Sun Jan  4 19:24:05 2009
@@ -747,10 +747,10 @@
 /// Note that this routine emits an error if you call it with ::new or ::delete
 /// as the current tokens, so only call it in contexts where these are invalid.
 bool Parser::TryAnnotateTypeOrScopeToken(const Token *GlobalQualifier) {
-  // FIXME: what about template-ids?
-  if (Tok.is(tok::annot_qualtypename) || Tok.is(tok::annot_cxxscope))
-    return false;
-
+  assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&
+         "Cannot be a type or scope token!");
+  
+  // FIXME: Implement template-ids
   CXXScopeSpec SS;
   if (getLang().CPlusPlus)
     MaybeParseCXXScopeSpecifier(SS, GlobalQualifier);
@@ -818,9 +818,8 @@
 bool Parser::TryAnnotateCXXScopeToken() {
   assert(getLang().CPlusPlus &&
          "Call sites of this function should be guarded by checking for C++");
-
-  if (Tok.is(tok::annot_cxxscope))
-    return false;
+  assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&
+         "Cannot be a type or scope token!");
 
   CXXScopeSpec SS;
   if (!MaybeParseCXXScopeSpecifier(SS))





More information about the cfe-commits mailing list