[cfe-commits] r52503 - /cfe/trunk/lib/Parse/Parser.cpp

Mike Stump mrs at apple.com
Thu Jun 19 12:28:49 PDT 2008


Author: mrs
Date: Thu Jun 19 14:28:49 2008
New Revision: 52503

URL: http://llvm.org/viewvc/llvm-project?rev=52503&view=rev
Log:
Test commit to see if new account works.

I choose to remove extraneous whitespace at end of lines as a semantic
nop for the test.

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

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

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Thu Jun 19 14:28:49 2008
@@ -41,10 +41,10 @@
 /// should be the name of the unmatched LHS token.
 SourceLocation Parser::MatchRHSPunctuation(tok::TokenKind RHSTok,
                                            SourceLocation LHSLoc) {
-  
+
   if (Tok.is(RHSTok))
     return ConsumeAnyToken();
-    
+
   SourceLocation R = Tok.getLocation();
   const char *LHSName = "unknown";
   diag::kind DID = diag::err_parse_error;
@@ -73,7 +73,7 @@
     ConsumeAnyToken();
     return false;
   }
-  
+
   Diag(Tok, DiagID, Msg);
   if (SkipToTok != tok::unknown)
     SkipUntil(SkipToTok);
@@ -89,9 +89,9 @@
 /// token will ever occur, this skips to the next token, or to some likely
 /// good stopping point.  If StopAtSemi is true, skipping will stop at a ';'
 /// character.
-/// 
+///
 /// If SkipUntil finds the specified token, it returns true, otherwise it
-/// returns false.  
+/// returns false.
 bool Parser::SkipUntil(const tok::TokenKind *Toks, unsigned NumToks,
                        bool StopAtSemi, bool DontConsume) {
   // We always want this function to skip at least one token if the first token
@@ -109,12 +109,12 @@
         return true;
       }
     }
-    
+
     switch (Tok.getKind()) {
     case tok::eof:
       // Ran out of tokens.
       return false;
-      
+
     case tok::l_paren:
       // Recursively skip properly-nested parens.
       ConsumeParen();
@@ -130,7 +130,7 @@
       ConsumeBrace();
       SkipUntil(tok::r_brace, false);
       break;
-      
+
     // Okay, we found a ']' or '}' or ')', which we think should be balanced.
     // Since the user wasn't looking for this token (if they were, it would
     // already be handled), this isn't balanced.  If there is a LHS token at a
@@ -151,7 +151,7 @@
         return false;  // Matches something.
       ConsumeBrace();
       break;
-      
+
     case tok::string_literal:
     case tok::wide_string_literal:
       ConsumeStringToken();
@@ -166,7 +166,7 @@
       break;
     }
     isFirstTokenSkipped = false;
-  }  
+  }
 }
 
 //===----------------------------------------------------------------------===//
@@ -192,10 +192,10 @@
   // decls in it.
   if (!CurScope->decl_empty())
     Actions.ActOnPopScope(Tok.getLocation(), CurScope);
-  
+
   Scope *OldScope = CurScope;
   CurScope = OldScope->getParent();
-  
+
   if (NumCachedScopes == ScopeCacheSize)
     delete OldScope;
   else
@@ -212,7 +212,7 @@
 Parser::~Parser() {
   // If we still have scopes active, delete the scope tree.
   delete CurScope;
-  
+
   // Free the scope cache.
   for (unsigned i = 0, e = NumCachedScopes; i != e; ++i)
     delete ScopeCache[i];
@@ -223,16 +223,16 @@
 void Parser::Initialize() {
   // Prime the lexer look-ahead.
   ConsumeToken();
-  
+
   // Create the translation unit scope.  Install it as the current scope.
   assert(CurScope == 0 && "A scope is already active?");
   EnterScope(Scope::DeclScope);
   Actions.ActOnTranslationUnitScope(Tok.getLocation(), CurScope);
-  
+
   if (Tok.is(tok::eof) &&
       !getLang().CPlusPlus)  // Empty source file is an extension in C
     Diag(Tok, diag::ext_empty_source_file);
-  
+
   // Initialization for Objective-C context sensitive keywords recognition.
   // Referenced in Parser::ParseObjCTypeQualifierList.
   if (getLang().ObjC1) {
@@ -248,11 +248,11 @@
     ObjCPropertyAttrs[objc_getter] = &PP.getIdentifierTable().get("getter");
     ObjCPropertyAttrs[objc_setter] = &PP.getIdentifierTable().get("setter");
     ObjCPropertyAttrs[objc_assign] = &PP.getIdentifierTable().get("assign");
-    ObjCPropertyAttrs[objc_readwrite] = 
+    ObjCPropertyAttrs[objc_readwrite] =
                                   &PP.getIdentifierTable().get("readwrite");
     ObjCPropertyAttrs[objc_retain] = &PP.getIdentifierTable().get("retain");
     ObjCPropertyAttrs[objc_copy] = &PP.getIdentifierTable().get("copy");
-    ObjCPropertyAttrs[objc_nonatomic] = 
+    ObjCPropertyAttrs[objc_nonatomic] =
                                   &PP.getIdentifierTable().get("nonatomic");
     ObjCForCollectionInKW = &PP.getIdentifierTable().get("in");
   }
@@ -263,7 +263,7 @@
 bool Parser::ParseTopLevelDecl(DeclTy*& Result) {
   Result = 0;
   if (Tok.is(tok::eof)) return true;
-  
+
   Result = ParseExternalDeclaration();
   return false;
 }
@@ -277,15 +277,15 @@
 
 /// ParseTranslationUnit:
 ///       translation-unit: [C99 6.9]
-///         external-declaration 
-///         translation-unit external-declaration 
+///         external-declaration
+///         translation-unit external-declaration
 void Parser::ParseTranslationUnit() {
   Initialize();
-  
+
   DeclTy *Res;
   while (!ParseTopLevelDecl(Res))
     /*parse them all*/;
-  
+
   Finalize();
 }
 
@@ -322,7 +322,7 @@
   }
   case tok::kw_asm: {
     ExprResult Result = ParseSimpleAsm();
-    
+
     ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
                      "top-level asm block");
 
@@ -359,7 +359,7 @@
 ///       function-definition: [C99 6.9.1]
 ///         decl-specs      declarator declaration-list[opt] compound-statement
 /// [C90] function-definition: [C99 6.7.1] - implicit int result
-/// [C90]   decl-specs[opt] declarator declaration-list[opt] compound-statement 
+/// [C90]   decl-specs[opt] declarator declaration-list[opt] compound-statement
 ///
 ///       declaration: [C99 6.7]
 ///         declaration-specifiers init-declarator-list[opt] ';'
@@ -370,14 +370,14 @@
   // Parse the common declaration-specifiers piece.
   DeclSpec DS;
   ParseDeclarationSpecifiers(DS);
-    
+
   // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
   // declaration-specifiers init-declarator-list[opt] ';'
   if (Tok.is(tok::semi)) {
     ConsumeToken();
     return Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
   }
-  
+
   // ObjC2 allows prefix attributes on class interfaces.
   if (getLang().ObjC2 && Tok.is(tok::at)) {
     SourceLocation AtLoc = ConsumeToken(); // the "@"
@@ -389,9 +389,9 @@
     const char *PrevSpec = 0;
     if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec))
       Diag(AtLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
-    return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes()); 
+    return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes());
   }
-  
+
   // If the declspec consisted only of 'extern' and we have a string
   // literal following it, this must be a C++ linkage specifier like
   // 'extern "C"'.
@@ -424,10 +424,10 @@
               isDeclarationSpecifier())) {      // int X(f) int f; {}
     if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
       Diag(Tok, diag::err_function_declared_typedef);
-      
+
       if (Tok.is(tok::l_brace)) {
         // This recovery skips the entire function body. It would be nice
-        // to simply call ParseFunctionDefintion() below, however Sema 
+        // to simply call ParseFunctionDefintion() below, however Sema
         // assumes the declarator represents a function, not a typedef.
         ConsumeBrace();
         SkipUntil(tok::r_brace, true);
@@ -457,14 +457,14 @@
 ///       function-definition: [C99 6.9.1]
 ///         decl-specs      declarator declaration-list[opt] compound-statement
 /// [C90] function-definition: [C99 6.7.1] - implicit int result
-/// [C90]   decl-specs[opt] declarator declaration-list[opt] compound-statement 
+/// [C90]   decl-specs[opt] declarator declaration-list[opt] compound-statement
 ///
 Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
   const DeclaratorChunk &FnTypeInfo = D.getTypeObject(0);
   assert(FnTypeInfo.Kind == DeclaratorChunk::Function &&
          "This isn't a function declarator!");
   const DeclaratorChunk::FunctionTypeInfo &FTI = FnTypeInfo.Fun;
-  
+
   // If this is C90 and the declspecs were completely missing, fudge in an
   // implicit int.  We do this here because this is the only place where
   // declaration-specifiers are completely optional in the grammar.
@@ -473,7 +473,7 @@
     D.getDeclSpec().SetTypeSpecType(DeclSpec::TST_int, D.getIdentifierLoc(),
                                     PrevSpec);
   }
-  
+
   // If this declaration was formed with a K&R-style identifier list for the
   // arguments, parse declarations for all of the args next.
   // int foo(a,b) int a; float b; {}
@@ -486,22 +486,22 @@
 
     // Skip over garbage, until we get to '{'.  Don't eat the '{'.
     SkipUntil(tok::l_brace, true, true);
-    
+
     // If we didn't find the '{', bail out.
     if (Tok.isNot(tok::l_brace))
       return 0;
   }
-  
+
   SourceLocation BraceLoc = Tok.getLocation();
-  
+
   // Enter a scope for the function body.
   EnterScope(Scope::FnScope|Scope::DeclScope);
-  
+
   // Tell the actions module that we have entered a function definition with the
   // specified Declarator for the function.
   DeclTy *Res = Actions.ActOnStartOfFunctionDef(CurScope, D);
-  
-  return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);  
+
+  return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);
 }
 
 /// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides
@@ -517,11 +517,11 @@
   // Read all the argument declarations.
   while (isDeclarationSpecifier()) {
     SourceLocation DSStart = Tok.getLocation();
-    
+
     // Parse the common declaration-specifiers piece.
     DeclSpec DS;
     ParseDeclarationSpecifiers(DS);
-    
+
     // C99 6.9.1p6: 'each declaration in the declaration list shall have at
     // least one declarator'.
     // NOTE: GCC just makes this an ext-warn.  It's not clear what it does with
@@ -532,7 +532,7 @@
       ConsumeToken();
       continue;
     }
-    
+
     // C99 6.9.1p6: Declarations shall contain no storage-class specifiers other
     // than register.
     if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified &&
@@ -546,7 +546,7 @@
            diag::err_invalid_storage_class_in_func_decl);
       DS.ClearStorageClassSpecs();
     }
-    
+
     // Parse the first declarator attached to this declspec.
     Declarator ParmDeclarator(DS, Declarator::KNRTypeListContext);
     ParseDeclarator(ParmDeclarator);
@@ -558,12 +558,12 @@
       if (Tok.is(tok::kw___attribute))
         // FIXME: attach attributes too.
         AttrList = ParseAttributes();
-      
+
       // Ask the actions module to compute the type for this declarator.
-      Action::DeclTy *Param = 
+      Action::DeclTy *Param =
         Actions.ActOnParamDeclarator(CurScope, ParmDeclarator);
 
-      if (Param && 
+      if (Param &&
           // A missing identifier has already been diagnosed.
           ParmDeclarator.getIdentifier()) {
 
@@ -577,7 +577,7 @@
                  ParmDeclarator.getIdentifier()->getName());
             break;
           }
-          
+
           if (FTI.ArgInfo[i].Ident == ParmDeclarator.getIdentifier()) {
             // Reject redefinitions of parameters.
             if (FTI.ArgInfo[i].Param) {
@@ -596,15 +596,15 @@
       // an error, bail out.
       if (Tok.isNot(tok::comma))
         break;
-      
+
       // Consume the comma.
       ConsumeToken();
-      
+
       // Parse the next declarator.
       ParmDeclarator.clear();
       ParseDeclarator(ParmDeclarator);
     }
-    
+
     if (Tok.is(tok::semi)) {
       ConsumeToken();
     } else {
@@ -615,7 +615,7 @@
         ConsumeToken();
     }
   }
-  
+
   // Leave prototype scope.
   ExitScope();
 
@@ -634,12 +634,12 @@
     Diag(Tok, diag::err_expected_string_literal);
     return true;
   }
-  
+
   ExprResult Res = ParseStringLiteralExpression();
   if (Res.isInvalid) return true;
-  
+
   // TODO: Diagnose: wide string literal in 'asm'
-    
+
   return Res;
 }
 
@@ -651,18 +651,18 @@
 Parser::ExprResult Parser::ParseSimpleAsm() {
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = ConsumeToken();
-  
+
   if (Tok.isNot(tok::l_paren)) {
     Diag(Tok, diag::err_expected_lparen_after, "asm");
     return true;
   }
-  
+
   ConsumeParen();
-  
+
   ExprResult Result = ParseAsmStringLiteral();
-  
+
   MatchRHSPunctuation(tok::r_paren, Loc);
-  
+
   return Result;
 }
 





More information about the cfe-commits mailing list