[cfe-commits] r54353 - in /cfe/trunk: Driver/PrintParserCallbacks.cpp include/clang/Parse/Action.h include/clang/Parse/DeclSpec.h lib/Parse/MinimalAction.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp

Daniel Dunbar daniel at zuster.org
Tue Aug 5 09:28:25 PDT 2008


Author: ddunbar
Date: Tue Aug  5 11:28:08 2008
New Revision: 54353

URL: http://llvm.org/viewvc/llvm-project?rev=54353&view=rev
Log:
Move AsmLabel into Declarator instead of just a parameter to
  ActOnDeclarator.

Modified:
    cfe/trunk/Driver/PrintParserCallbacks.cpp
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/DeclSpec.h
    cfe/trunk/lib/Parse/MinimalAction.cpp
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/Driver/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintParserCallbacks.cpp?rev=54353&r1=54352&r2=54353&view=diff

==============================================================================
--- cfe/trunk/Driver/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/Driver/PrintParserCallbacks.cpp Tue Aug  5 11:28:08 2008
@@ -30,7 +30,7 @@
     /// and 'Init' specifies the initializer if any.  This is for things like:
     /// "int X = 4" or "typedef int foo".
     virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,
-                                    DeclTy *LastInGroup, ExprTy *AsmLabel) {
+                                    DeclTy *LastInGroup) {
       llvm::cout << __FUNCTION__ << " ";
       if (IdentifierInfo *II = D.getIdentifier()) {
         llvm::cout << "'" << II->getName() << "'";
@@ -40,7 +40,7 @@
       llvm::cout << "\n";
       
       // Pass up to EmptyActions so that the symbol table is maintained right.
-      return MinimalAction::ActOnDeclarator(S, D, LastInGroup, AsmLabel);
+      return MinimalAction::ActOnDeclarator(S, D, LastInGroup);
     }
     /// ActOnPopScope - This callback is called immediately before the specified
     /// scope is popped and deleted.

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=54353&r1=54352&r2=54353&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue Aug  5 11:28:08 2008
@@ -105,12 +105,7 @@
   /// LastInGroup is non-null for cases where one declspec has multiple
   /// declarators on it.  For example in 'int A, B', ActOnDeclarator will be
   /// called with LastInGroup=A when invoked for B.
-  ///
-  /// AsmLabel is non-null only for top-level function declarations
-  /// which use the GCC asm-label extension (the expression must be a
-  /// constant string).
-  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
-                                  ExprTy *AsmLabel) {
+  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,DeclTy *LastInGroup) {
     return 0;
   }
 
@@ -144,7 +139,7 @@
   virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
     // Default to ActOnDeclarator.
     return ActOnStartOfFunctionDef(FnBodyScope,
-                                   ActOnDeclarator(FnBodyScope, D, 0, 0));
+                                   ActOnDeclarator(FnBodyScope, D, 0));
   }
 
   /// ActOnStartOfFunctionDef - This is called at the start of a function
@@ -839,8 +834,7 @@
   /// ActOnDeclarator - If this is a typedef declarator, we modify the
   /// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
   /// popped.
-  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
-                                  ExprTy *AsmLabel);
+  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
   
   /// ActOnPopScope - When a scope is popped, if any typedefs are now 
   /// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field.

Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=54353&r1=54352&r2=54353&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Tue Aug  5 11:28:08 2008
@@ -580,11 +580,16 @@
   // InvalidType - Set by Sema::GetTypeForDeclarator().
   bool InvalidType;
 
-  // attributes.
+  /// AttrList - Attributes.
   AttributeList *AttrList;
+  
+  /// AsmLabel - The asm label, if specified.
+  Action::ExprTy *AsmLabel;
+  
 public:
   Declarator(DeclSpec &ds, TheContext C)
-    : DS(ds), Identifier(0), Context(C), InvalidType(false), AttrList(0) {
+    : DS(ds), Identifier(0), Context(C), InvalidType(false), AttrList(0),
+      AsmLabel(0) {
   }
   
   ~Declarator() {
@@ -694,7 +699,10 @@
   }
   const AttributeList *getAttributes() const { return AttrList; }
   AttributeList *getAttributes() { return AttrList; }
-  
+
+  void setAsmLabel(Action::ExprTy *E) { AsmLabel = E; }
+  Action::ExprTy *getAsmLabel() const { return AsmLabel; }
+
   void setInvalidType(bool flag) { InvalidType = flag; }
   bool getInvalidType() const { return InvalidType; }
 };

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

==============================================================================
--- cfe/trunk/lib/Parse/MinimalAction.cpp (original)
+++ cfe/trunk/lib/Parse/MinimalAction.cpp Tue Aug  5 11:28:08 2008
@@ -63,8 +63,7 @@
 /// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
 /// popped.
 Action::DeclTy *
-MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
-                               ExprTy *AsmLabel) {
+MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup) {
   IdentifierInfo *II = D.getIdentifier();
   
   // If there is no identifier associated with this declarator, bail out.

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Aug  5 11:28:08 2008
@@ -256,13 +256,14 @@
   // rest of the init-declarator-list.
   while (1) {
     // If a simple-asm-expr is present, parse it.
-    ExprResult AsmLabel;
     if (Tok.is(tok::kw_asm)) {
-      AsmLabel = ParseSimpleAsm();
+      ExprResult AsmLabel = ParseSimpleAsm();
       if (AsmLabel.isInvalid) {
         SkipUntil(tok::semi);
         return 0;
       }
+      
+      D.setAsmLabel(AsmLabel.Val);
     }
     
     // If attributes are present, parse them.
@@ -271,8 +272,7 @@
 
     // Inform the current actions module that we just parsed this declarator.
     // FIXME: pass asm & attributes.
-    LastDeclInGroup = Actions.ActOnDeclarator(CurScope, D, LastDeclInGroup,
-                                              AsmLabel.Val);
+    LastDeclInGroup = Actions.ActOnDeclarator(CurScope, D, LastDeclInGroup);
         
     // Parse declarator '=' initializer.
     if (Tok.is(tok::equal)) {

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Aug  5 11:28:08 2008
@@ -1222,7 +1222,7 @@
           ParseDeclarator(DeclaratorInfo);
           if (DeclaratorInfo.getIdentifier()) {
             DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope, 
-                                                            DeclaratorInfo, 0, 0);
+                                                          DeclaratorInfo, 0);
             StmtResult stmtResult =
               Actions.ActOnDeclStmt(aBlockVarDecl, 
                                     DS.getSourceRange().getBegin(),

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=54353&r1=54352&r2=54353&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Aug  5 11:28:08 2008
@@ -211,8 +211,7 @@
   // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
   //
   virtual TypeTy *isTypeName(const IdentifierInfo &II, Scope *S);
-  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
-                                  ExprTy *AsmLabel);
+  virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
   virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D);
   virtual void ActOnParamDefaultArgument(DeclTy *param, 
                                          SourceLocation EqualLoc,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=54353&r1=54352&r2=54353&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug  5 11:28:08 2008
@@ -609,7 +609,7 @@
 }
 
 Sema::DeclTy *
-Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl, ExprTy *AsmLabel) {
+Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
   ScopedDecl *LastDeclarator = dyn_cast_or_null<ScopedDecl>((Decl *)lastDecl);
   IdentifierInfo *II = D.getIdentifier();
   
@@ -701,7 +701,7 @@
     ProcessDeclAttributes(NewFD, D);
 
     // Handle GNU asm-label extension (encoded as an attribute).
-    if (Expr *E = (Expr*) AsmLabel) {
+    if (Expr *E = (Expr*) D.getAsmLabel()) {
       // The parser guarantees this is a string.
       StringLiteral *SE = cast<StringLiteral>(E);  
       NewFD->addAttr(new AsmLabelAttr(std::string(SE->getStrData(),
@@ -1577,7 +1577,7 @@
   }
 
   return ActOnStartOfFunctionDef(FnBodyScope,
-                                 ActOnDeclarator(GlobalScope, D, 0, 0));
+                                 ActOnDeclarator(GlobalScope, D, 0));
 }
 
 Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
@@ -1669,7 +1669,7 @@
   CurContext = Context.getTranslationUnitDecl();
  
   FunctionDecl *FD = 
-    dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(TUScope, D, 0, 0)));
+    dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(TUScope, D, 0)));
   FD->setImplicit();
 
   CurContext = PrevDC;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=54353&r1=54352&r2=54353&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Aug  5 11:28:08 2008
@@ -371,7 +371,7 @@
   if (isInstField)
     Member = static_cast<Decl*>(ActOnField(S, Loc, D, BitWidth));
   else
-    Member = static_cast<Decl*>(ActOnDeclarator(S, D, LastInGroup, 0));
+    Member = static_cast<Decl*>(ActOnDeclarator(S, D, LastInGroup));
 
   if (!Member) return LastInGroup;
 





More information about the cfe-commits mailing list