[cfe-commits] r68869 - in /cfe/trunk: include/clang/Parse/Action.h include/clang/Parse/AttributeList.h include/clang/Parse/DeclSpec.h include/clang/Parse/Designator.h include/clang/Parse/Ownership.h lib/Parse/AttributeList.cpp

Chris Lattner sabre at nondot.org
Sat Apr 11 11:48:18 PDT 2009


Author: lattner
Date: Sat Apr 11 13:48:18 2009
New Revision: 68869

URL: http://llvm.org/viewvc/llvm-project?rev=68869&view=rev
Log:
sink abstract typedefs like Action::ExprTy from the Action class
down to the ActionBase class.  This eliminates dependencies of (e.g.)
DeclSpec.h on Action.h, meaning that action.h can now include these
headers and use their types directly in the actions interfaces.

This is a refactoring to support a future change, no functionality
change.

Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/AttributeList.h
    cfe/trunk/include/clang/Parse/DeclSpec.h
    cfe/trunk/include/clang/Parse/Designator.h
    cfe/trunk/include/clang/Parse/Ownership.h
    cfe/trunk/lib/Parse/AttributeList.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sat Apr 11 13:48:18 2009
@@ -19,6 +19,7 @@
 #include "clang/Basic/TemplateKinds.h"
 #include "clang/Basic/TypeTraits.h"
 #include "clang/Parse/AccessSpecifier.h"
+#include "clang/Parse/DeclSpec.h"
 #include "clang/Parse/Ownership.h"
 #include "llvm/Support/PrettyStackTrace.h"
 
@@ -70,15 +71,6 @@
   // what types are required to be identical for the actions.
   typedef ActionBase::ExprTy ExprTy;
   typedef ActionBase::StmtTy StmtTy;
-  typedef OpaquePtr<0> DeclPtrTy;
-  typedef OpaquePtr<1> DeclGroupPtrTy;
-  typedef void TypeTy;  // FIXME: Change TypeTy to use OpaquePtr<N>.
-  typedef OpaquePtr<2> TemplateTy;
-  typedef void AttrTy;
-  typedef void BaseTy;
-  typedef void MemInitTy;
-  typedef void CXXScopeTy;
-  typedef void TemplateParamsTy;
 
   /// Expr/Stmt/Type/BaseResult - Provide a unique type to wrap
   /// ExprTy/StmtTy/TypeTy/BaseTy, providing strong typing and

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

==============================================================================
--- cfe/trunk/include/clang/Parse/AttributeList.h (original)
+++ cfe/trunk/include/clang/Parse/AttributeList.h Sat Apr 11 13:48:18 2009
@@ -14,10 +14,13 @@
 #ifndef LLVM_CLANG_ATTRLIST_H
 #define LLVM_CLANG_ATTRLIST_H
 
-#include "clang/Parse/Action.h"
+#include "clang/Parse/Ownership.h"
+#include "clang/Basic/SourceLocation.h"
 #include <cassert>
 
 namespace clang {
+  class IdentifierInfo;
+  class Action;
   
 /// AttributeList - Represents GCC's __attribute__ declaration. There are
 /// 4 forms of this construct...they are:
@@ -32,7 +35,7 @@
   SourceLocation AttrLoc;
   IdentifierInfo *ParmName;
   SourceLocation ParmLoc;
-  Action::ExprTy **Args;
+  ActionBase::ExprTy **Args;
   unsigned NumArgs;
   AttributeList *Next;
   AttributeList(const AttributeList &); // DO NOT IMPLEMENT
@@ -40,7 +43,8 @@
 public:
   AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc,
                 IdentifierInfo *ParmName, SourceLocation ParmLoc,
-                Action::ExprTy **args, unsigned numargs, AttributeList *Next);
+                ActionBase::ExprTy **args, unsigned numargs,
+                AttributeList *Next);
   ~AttributeList();
   
   enum Kind {              // Please keep this list alphabetized.
@@ -115,16 +119,16 @@
   unsigned getNumArgs() const { return NumArgs; }
   
   /// getArg - Return the specified argument.
-  Action::ExprTy *getArg(unsigned Arg) const {
+  ActionBase::ExprTy *getArg(unsigned Arg) const {
     assert(Arg < NumArgs && "Arg access out of range!");
     return Args[Arg];
   }
   
   class arg_iterator {
-    Action::ExprTy** X;
+    ActionBase::ExprTy** X;
     unsigned Idx;
   public:
-    arg_iterator(Action::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}    
+    arg_iterator(ActionBase::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}    
 
     arg_iterator& operator++() {
       ++Idx;
@@ -141,7 +145,7 @@
       return !operator==(I);
     }
     
-    Action::ExprTy* operator*() const {
+    ActionBase::ExprTy* operator*() const {
       return X[Idx];
     }
     

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

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Sat Apr 11 13:48:18 2009
@@ -14,15 +14,17 @@
 #ifndef LLVM_CLANG_PARSE_DECLSPEC_H
 #define LLVM_CLANG_PARSE_DECLSPEC_H
 
-#include "clang/Parse/Action.h"
 #include "clang/Parse/AttributeList.h"
 #include "clang/Lex/Token.h"
+#include "clang/Basic/OperatorKinds.h"
 #include "llvm/ADT/SmallVector.h"
 
 namespace clang {
   class LangOptions;
   class Diagnostic;
   class IdentifierInfo;
+  class Preprocessor;
+  class Declarator;
   
 /// DeclSpec - This class captures information about "declaration specifiers",
 /// which encompasses storage-class-specifiers, type-specifiers,
@@ -124,7 +126,7 @@
   /// TypeRep - This contains action-specific information about a specific TST.
   /// For example, for a typedef or struct, it might contain the declaration for
   /// these.
-  Action::TypeTy *TypeRep;  
+  ActionBase::TypeTy *TypeRep;  
   
   // attributes.
   AttributeList *AttrList;
@@ -132,7 +134,7 @@
   // List of protocol qualifiers for objective-c classes.  Used for 
   // protocol-qualified interfaces "NString<foo>" and protocol-qualified id
   // "id<foo>".
-  const Action::DeclPtrTy *ProtocolQualifiers;
+  const ActionBase::DeclPtrTy *ProtocolQualifiers;
   unsigned NumProtocolQualifiers;
   
   // SourceLocation info.  These are null if the item wasn't specified or if
@@ -307,17 +309,17 @@
     return AL;
   }
   
-  typedef const Action::DeclPtrTy *ProtocolQualifierListTy;
+  typedef const ActionBase::DeclPtrTy *ProtocolQualifierListTy;
   ProtocolQualifierListTy getProtocolQualifiers() const {
     return ProtocolQualifiers;
   }
   unsigned getNumProtocolQualifiers() const {
     return NumProtocolQualifiers;
   }
-  void setProtocolQualifiers(const Action::DeclPtrTy *Protos, unsigned NP) {
+  void setProtocolQualifiers(const ActionBase::DeclPtrTy *Protos, unsigned NP) {
     if (NP == 0) return;
-    ProtocolQualifiers = new Action::DeclPtrTy[NP];
-    memcpy((void*)ProtocolQualifiers, Protos, sizeof(Action::DeclPtrTy)*NP);
+    ProtocolQualifiers = new ActionBase::DeclPtrTy[NP];
+    memcpy((void*)ProtocolQualifiers, Protos, sizeof(ActionBase::DeclPtrTy)*NP);
     NumProtocolQualifiers = NP;
   }
   
@@ -408,8 +410,8 @@
   SourceLocation getBeginLoc() const { return Range.getBegin(); }
   SourceLocation getEndLoc() const { return Range.getEnd(); }
 
-  Action::CXXScopeTy *getScopeRep() const { return ScopeRep; }
-  void setScopeRep(Action::CXXScopeTy *S) { ScopeRep = S; }
+  ActionBase::CXXScopeTy *getScopeRep() const { return ScopeRep; }
+  void setScopeRep(ActionBase::CXXScopeTy *S) { ScopeRep = S; }
 
   bool isEmpty() const { return !Range.isValid(); }
   bool isNotEmpty() const { return !isEmpty(); }
@@ -475,7 +477,7 @@
     /// This is the size of the array, or null if [] or [*] was specified.
     /// Since the parser is multi-purpose, and we don't want to impose a root
     /// expression class on all clients, NumElts is untyped.
-    Action::ExprTy *NumElts;
+    ActionBase::ExprTy *NumElts;
     void destroy() {}
   };
   
@@ -488,7 +490,7 @@
   struct ParamInfo {
     IdentifierInfo *Ident;
     SourceLocation IdentLoc;
-    Action::DeclPtrTy Param;
+    ActionBase::DeclPtrTy Param;
 
     /// DefaultArgTokens - When the parameter's default argument
     /// cannot be parsed immediately (because it occurs within the
@@ -499,7 +501,7 @@
 
     ParamInfo() {}
     ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
-              Action::DeclPtrTy param,
+              ActionBase::DeclPtrTy param,
               CachedTokens *DefArgTokens = 0)
       : Ident(ident), IdentLoc(iloc), Param(param), 
         DefaultArgTokens(DefArgTokens) {}
@@ -760,13 +762,13 @@
   AttributeList *AttrList;
   
   /// AsmLabel - The asm label, if specified.
-  Action::ExprTy *AsmLabel;
+  ActionBase::ExprTy *AsmLabel;
 
   union {
     // When Kind is DK_Constructor, DK_Destructor, or DK_Conversion, the
     // type associated with the constructor, destructor, or conversion
     // operator.
-    Action::TypeTy *Type;
+    ActionBase::TypeTy *Type;
 
     /// When Kind is DK_Operator, this is the actual overloaded
     /// operator that this declarator names.
@@ -906,7 +908,7 @@
   
   /// setConstructor - Set this declarator to be a C++ constructor
   /// declarator. Also extends the range.
-  void setConstructor(Action::TypeTy *Ty, SourceLocation Loc) {
+  void setConstructor(ActionBase::TypeTy *Ty, SourceLocation Loc) {
     IdentifierLoc = Loc;
     Kind = DK_Constructor;
     Type = Ty;
@@ -916,9 +918,8 @@
   /// setDestructor - Set this declarator to be a C++ destructor
   /// declarator. Also extends the range to End, which should be the identifier
   /// token.
-  void setDestructor(Action::TypeTy *Ty, SourceLocation Loc,
-                     SourceLocation EndLoc)
-  {
+  void setDestructor(ActionBase::TypeTy *Ty, SourceLocation Loc,
+                     SourceLocation EndLoc) {
     IdentifierLoc = Loc;
     Kind = DK_Destructor;
     Type = Ty;
@@ -930,7 +931,7 @@
   /// conversion function declarator (e.g., @c operator int const *).
   /// Also extends the range to EndLoc, which should be the last token of the
   /// type name.
-  void setConversionFunction(Action::TypeTy *Ty, SourceLocation Loc,
+  void setConversionFunction(ActionBase::TypeTy *Ty, SourceLocation Loc,
                              SourceLocation EndLoc) {
     Identifier = 0;
     IdentifierLoc = Loc;
@@ -1005,10 +1006,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 setAsmLabel(ActionBase::ExprTy *E) { AsmLabel = E; }
+  ActionBase::ExprTy *getAsmLabel() const { return AsmLabel; }
 
-  Action::TypeTy *getDeclaratorIdType() const { return Type; }
+  ActionBase::TypeTy *getDeclaratorIdType() const { return Type; }
 
   OverloadedOperatorKind getOverloadedOperator() const { return OperatorKind; }
 
@@ -1025,7 +1026,7 @@
 /// structure field declarators, which is basically just a bitfield size.
 struct FieldDeclarator {
   Declarator D;
-  Action::ExprTy *BitfieldSize;
+  ActionBase::ExprTy *BitfieldSize;
   explicit FieldDeclarator(DeclSpec &DS) : D(DS, Declarator::MemberContext) {
     BitfieldSize = 0;
   }

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Designator.h (original)
+++ cfe/trunk/include/clang/Parse/Designator.h Sat Apr 11 13:48:18 2009
@@ -18,7 +18,7 @@
 #include "clang/Parse/Action.h"
 
 namespace clang {
-
+  
 /// Designator - This class is a discriminated union which holds the various
 /// different sorts of designators possible.  A Designation is an array of
 /// these.  An example of a designator are things like this:
@@ -41,12 +41,12 @@
     unsigned NameLoc;
   };
   struct ArrayDesignatorInfo {
-    Action::ExprTy *Index;
+    ActionBase::ExprTy *Index;
     unsigned LBracketLoc;
     mutable unsigned  RBracketLoc;
   };
   struct ArrayRangeDesignatorInfo {
-    Action::ExprTy *Start, *End;
+    ActionBase::ExprTy *Start, *End;
     unsigned LBracketLoc, EllipsisLoc;
     mutable unsigned RBracketLoc;
   };
@@ -79,16 +79,16 @@
     return SourceLocation::getFromRawEncoding(FieldInfo.NameLoc);
   }
   
-  Action::ExprTy *getArrayIndex() const {
+  ActionBase::ExprTy *getArrayIndex() const {
     assert(isArrayDesignator() && "Invalid accessor");
     return ArrayInfo.Index;
   }
 
-  Action::ExprTy *getArrayRangeStart() const {
+  ActionBase::ExprTy *getArrayRangeStart() const {
     assert(isArrayRangeDesignator() && "Invalid accessor");
     return ArrayRangeInfo.Start;
   }
-  Action::ExprTy *getArrayRangeEnd() const {
+  ActionBase::ExprTy *getArrayRangeEnd() const {
     assert(isArrayRangeDesignator() && "Invalid accessor");
     return ArrayRangeInfo.End;
   }
@@ -126,7 +126,8 @@
     return D;
   }
 
-  static Designator getArray(Action::ExprTy *Index, SourceLocation LBracketLoc) {
+  static Designator getArray(ActionBase::ExprTy *Index,
+                             SourceLocation LBracketLoc) {
     Designator D;
     D.Kind = ArrayDesignator;
     D.ArrayInfo.Index = Index;
@@ -135,7 +136,8 @@
     return D;
   }
   
-  static Designator getArrayRange(Action::ExprTy *Start, Action::ExprTy *End,
+  static Designator getArrayRange(ActionBase::ExprTy *Start,
+                                  ActionBase::ExprTy *End,
                                   SourceLocation LBracketLoc, 
                                   SourceLocation EllipsisLoc) {
     Designator D;

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Ownership.h (original)
+++ cfe/trunk/include/clang/Parse/Ownership.h Sat Apr 11 13:48:18 2009
@@ -201,9 +201,17 @@
 
     // Types - Though these don't actually enforce strong typing, they document
     // what types are required to be identical for the actions.
+    typedef OpaquePtr<0> DeclPtrTy;
+    typedef OpaquePtr<1> DeclGroupPtrTy;
+    typedef OpaquePtr<2> TemplateTy;
+    typedef void AttrTy;
+    typedef void BaseTy;
+    typedef void MemInitTy;
     typedef void ExprTy;
     typedef void StmtTy;
     typedef void TemplateParamsTy;
+    typedef void CXXScopeTy;
+    typedef void TypeTy;  // FIXME: Change TypeTy to use OpaquePtr<N>.
 
     /// ActionResult - This structure is used while parsing/acting on
     /// expressions, stmts, etc.  It encapsulates both the object returned by

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

==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Sat Apr 11 13:48:18 2009
@@ -12,11 +12,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Parse/AttributeList.h"
+#include "clang/Basic/IdentifierTable.h"
 using namespace clang;
 
 AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
                              IdentifierInfo *pName, SourceLocation pLoc,
-                             Action::ExprTy **ExprList, unsigned numArgs,
+                             ActionBase::ExprTy **ExprList, unsigned numArgs,
                              AttributeList *n)
   : AttrName(aName), AttrLoc(aLoc), ParmName(pName), ParmLoc(pLoc),
     NumArgs(numArgs), Next(n) {
@@ -24,7 +25,7 @@
   if (numArgs == 0)
     Args = 0;
   else {
-    Args = new Action::ExprTy*[numArgs];
+    Args = new ActionBase::ExprTy*[numArgs];
     memcpy(Args, ExprList, numArgs*sizeof(Args[0]));
   }
 }
@@ -32,7 +33,7 @@
 AttributeList::~AttributeList() {
   if (Args) {
     // FIXME: before we delete the vector, we need to make sure the Expr's 
-    // have been deleted. Since Action::ExprTy is "void", we are dependent
+    // have been deleted. Since ActionBase::ExprTy is "void", we are dependent
     // on the actions module for actually freeing the memory. The specific
     // hooks are ActOnDeclarator, ActOnTypeName, ActOnParamDeclaratorType, 
     // ParseField, ParseTag. Once these routines have freed the expression, 





More information about the cfe-commits mailing list