From: Chris Lattner Date: Sat, 6 Oct 2007 22:16:01 +0000 (+0000) Subject: Every decl has a SourceLocation, move the location info into the Decl class instead... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5ab7f31054e87ee812830480a828a762cd9eb73;p=clang Every decl has a SourceLocation, move the location info into the Decl class instead of being in subclasses. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42709 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 0b0a8580cc..fe2f4c2d89 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -54,6 +54,9 @@ public: }; private: + /// Loc - The location that this decl. + SourceLocation Loc; + /// DeclKind - This indicates which class this is. Kind DeclKind : 8; @@ -61,14 +64,16 @@ private: unsigned int InvalidDecl : 1; protected: - Decl(Kind DK) : DeclKind(DK), InvalidDecl(0) { + Decl(Kind DK, SourceLocation L) : Loc(L), DeclKind(DK), InvalidDecl(0) { if (Decl::CollectingStats()) addDeclKind(DK); } virtual ~Decl(); public: - + SourceLocation getLocation() const { return Loc; } + void setLocation(SourceLocation L) { Loc = L; } + Kind getKind() const { return DeclKind; } const char *getDeclKindName() const; @@ -113,9 +118,6 @@ class ScopedDecl : public Decl { /// variable, the tag for a struct). IdentifierInfo *Identifier; - /// Loc - The location that this decl. - SourceLocation Loc; - /// NextDeclarator - If this decl was part of a multi-declarator declaration, /// such as "int X, Y, *Z;" this indicates Decl for the next declarator. ScopedDecl *NextDeclarator; @@ -127,11 +129,9 @@ class ScopedDecl : public Decl { ScopedDecl *Next; protected: ScopedDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, ScopedDecl *PrevDecl) - : Decl(DK), Identifier(Id), Loc(L), NextDeclarator(PrevDecl), Next(0) {} + : Decl(DK, L), Identifier(Id), NextDeclarator(PrevDecl), Next(0) {} public: IdentifierInfo *getIdentifier() const { return Identifier; } - SourceLocation getLocation() const { return Loc; } - void setLocation(SourceLocation L) { Loc = L; } const char *getName() const; ScopedDecl *getNext() const { return Next; } @@ -329,20 +329,15 @@ class FieldDecl : public Decl { /// Identifier - The identifier for this declaration (e.g. the name for the /// variable, the tag for a struct). IdentifierInfo *Identifier; - - /// Loc - The location that this decl. - SourceLocation Loc; QualType DeclType; public: FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T) - : Decl(Field), Identifier(Id), Loc(L), DeclType(T) {} + : Decl(Field, L), Identifier(Id), DeclType(T) {} FieldDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T) - : Decl(DK), Identifier(Id), Loc(L), DeclType(T) {} + : Decl(DK, L), Identifier(Id), DeclType(T) {} IdentifierInfo *getIdentifier() const { return Identifier; } - SourceLocation getLocation() const { return Loc; } - void setLocation(SourceLocation L) { Loc = L; } const char *getName() const; QualType getType() const { return DeclType; } diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 17b7adc00a..9c1222dc60 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -220,20 +220,17 @@ private: /// List of attributes for this method declaration. AttributeList *MethodAttrs; - /// Loc - location of this declaration. - SourceLocation Loc; - public: ObjcMethodDecl(SourceLocation L, Selector SelInfo, QualType T, ParmVarDecl **paramInfo = 0, int numParams=-1, AttributeList *M = 0, bool isInstance = true, ImplementationControl impControl = None, Decl *PrevDecl = 0) - : Decl(ObjcMethod), + : Decl(ObjcMethod, L), IsInstance(isInstance), DeclImplementation(impControl), SelName(SelInfo), MethodDeclType(T), ParamInfo(paramInfo), NumMethodParams(numParams), - MethodAttrs(M), Loc(L) {} + MethodAttrs(M) {} virtual ~ObjcMethodDecl(); Selector getSelector() const { return SelName; } QualType getMethodType() const { return MethodDeclType; } @@ -251,7 +248,6 @@ public: void setMethodParams(ParmVarDecl **NewParamInfo, unsigned NumParams); AttributeList *getMethodAttrs() const {return MethodAttrs;} - SourceLocation getLocation() const { return Loc; } bool isInstance() const { return IsInstance; } // Related to protocols declared in @protocol void setDeclImplementation(ImplementationControl ic) @@ -455,17 +451,14 @@ class ObjcCategoryDecl : public Decl { /// Next category belonging to this class ObjcCategoryDecl *NextClassCategory; - /// Location of cetagory declaration - SourceLocation CatLoc; - public: ObjcCategoryDecl(SourceLocation L, unsigned numRefProtocol) - : Decl(ObjcCategory), + : Decl(ObjcCategory, L), ClassInterface(0), ObjcCatName(0), ReferencedProtocols(0), NumReferencedProtocols(-1), InstanceMethods(0), NumInstanceMethods(-1), ClassMethods(0), NumClassMethods(-1), - NextClassCategory(0), CatLoc(L) { + NextClassCategory(0) { if (numRefProtocol) { ReferencedProtocols = new ObjcProtocolDecl*[numRefProtocol]; memset(ReferencedProtocols, '\0', @@ -505,8 +498,6 @@ public: ClassInterface->setListCategories(this); } - SourceLocation getLocation() const { return CatLoc; } - static bool classof(const Decl *D) { return D->getKind() == ObjcCategory; } @@ -530,17 +521,15 @@ class ObjcCategoryImplDecl : public Decl { ObjcMethodDecl **ClassMethods; // Null if category is not implementing any int NumClassMethods; // -1 if category is not implementing any - SourceLocation Loc; - public: ObjcCategoryImplDecl(SourceLocation L, IdentifierInfo *Id, ObjcInterfaceDecl *classInterface, IdentifierInfo *catName) - : Decl(ObjcCategoryImpl), + : Decl(ObjcCategoryImpl, L), ClassInterface(classInterface), ObjcCatName(catName), InstanceMethods(0), NumInstanceMethods(-1), - ClassMethods(0), NumClassMethods(-1), Loc(L) {} + ClassMethods(0), NumClassMethods(-1) {} ObjcInterfaceDecl *getClassInterface() const { return ClassInterface; @@ -558,8 +547,6 @@ class ObjcCategoryImplDecl : public Decl { ObjcMethodDecl **insMethods, unsigned numInsMembers, ObjcMethodDecl **clsMethods, unsigned numClsMembers); - SourceLocation getLocation() const { return Loc; } - static bool classof(const Decl *D) { return D->getKind() == ObjcCategoryImpl; }