]> granicus.if.org Git - clang/commitdiff
sink abstract typedefs like Action::ExprTy from the Action class
authorChris Lattner <sabre@nondot.org>
Sat, 11 Apr 2009 18:48:18 +0000 (18:48 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 11 Apr 2009 18:48:18 +0000 (18:48 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68869 91177308-0d34-0410-b5e6-96231b3b80d8

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

index b1cb34a322433611399ee62426183d496cac3642..f8be3ff79a0ada3ff77c940cafa962e13a2673ea 100644 (file)
@@ -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 @@ public:
   // 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
index 751d370dda6e017bf8a55312a07d2edc6a85d66d..fd5d3e29fc695f1d044fdb4d9a1f5c1dc0756348 100644 (file)
 #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 @@ class AttributeList {
   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 @@ class AttributeList {
 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 @@ public:
   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 @@ public:
       return !operator==(I);
     }
     
-    Action::ExprTy* operator*() const {
+    ActionBase::ExprTy* operator*() const {
       return X[Idx];
     }
     
index 5d78192e1d1b077f20c3c808defe122e0b9498a8..c3c07b7f4a144a1b8f789b75218bb6b7eb6a2839 100644 (file)
 #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 @@ private:
   /// 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 @@ private:
   // 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 @@ public:
     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 @@ public:
   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 @@ struct DeclaratorChunk {
     /// 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 DeclaratorChunk {
   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 @@ struct DeclaratorChunk {
 
     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 @@ private:
   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 @@ public:
   
   /// 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 @@ public:
   /// 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 @@ public:
   /// 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 @@ public:
   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 @@ public:
 /// 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;
   }
index 05db2594ca848bddf7e111d8a6c57efc2bd16105..026286d318fb817bb48caf29843c417fcc000928 100644 (file)
@@ -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 @@ private:
     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 @@ public:
     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 @@ public:
     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 @@ public:
     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;
index f9ba5ea70bc9b7d370a6c21d840e4a567a227600..652fc46505da475390f449a59b51d55ffb043298 100644 (file)
@@ -201,9 +201,17 @@ namespace clang {
 
     // 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
index 14011e5b6f15c2b2955efd85580fa42746887dd7..d69755df73dd945e5d9d426907188931bb222494 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #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 @@ AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
   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(IdentifierInfo *aName, SourceLocation aLoc,
 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,