diff options
-rw-r--r-- | include/clang/Parse/Action.h | 10 | ||||
-rw-r--r-- | include/clang/Parse/AttributeList.h | 18 | ||||
-rw-r--r-- | include/clang/Parse/DeclSpec.h | 47 | ||||
-rw-r--r-- | include/clang/Parse/Designator.h | 18 | ||||
-rw-r--r-- | include/clang/Parse/Ownership.h | 8 | ||||
-rw-r--r-- | lib/Parse/AttributeList.cpp | 7 |
6 files changed, 58 insertions, 50 deletions
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index b1cb34a322..f8be3ff79a 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -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 diff --git a/include/clang/Parse/AttributeList.h b/include/clang/Parse/AttributeList.h index 751d370dda..fd5d3e29fc 100644 --- a/include/clang/Parse/AttributeList.h +++ b/include/clang/Parse/AttributeList.h @@ -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 @@ 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]; } diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h index 5d78192e1d..c3c07b7f4a 100644 --- a/include/clang/Parse/DeclSpec.h +++ b/include/clang/Parse/DeclSpec.h @@ -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 @@ 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; } diff --git a/include/clang/Parse/Designator.h b/include/clang/Parse/Designator.h index 05db2594ca..026286d318 100644 --- a/include/clang/Parse/Designator.h +++ b/include/clang/Parse/Designator.h @@ -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; diff --git a/include/clang/Parse/Ownership.h b/include/clang/Parse/Ownership.h index f9ba5ea70b..652fc46505 100644 --- a/include/clang/Parse/Ownership.h +++ b/include/clang/Parse/Ownership.h @@ -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 diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index 14011e5b6f..d69755df73 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -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 @@ 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, |