[cfe-commits] r42709 - in /cfe/trunk/include/clang/AST: Decl.h DeclObjC.h

Chris Lattner sabre at nondot.org
Sat Oct 6 15:16:01 PDT 2007


Author: lattner
Date: Sat Oct  6 17:16:01 2007
New Revision: 42709

URL: http://llvm.org/viewvc/llvm-project?rev=42709&view=rev
Log:
Every decl has a SourceLocation, move the location info into the Decl class instead of being in subclasses.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclObjC.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=42709&r1=42708&r2=42709&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Oct  6 17:16:01 2007
@@ -54,6 +54,9 @@
   };
   
 private:
+  /// Loc - The location that this decl.
+  SourceLocation Loc;
+
   /// DeclKind - This indicates which class this is.
   Kind DeclKind   :  8;
   
@@ -61,14 +64,16 @@
   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 @@
   /// 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 @@
   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 @@
   /// 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; }

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=42709&r1=42708&r2=42709&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Oct  6 17:16:01 2007
@@ -220,20 +220,17 @@
   /// 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 @@
   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 @@
   /// 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 @@
     ClassInterface->setListCategories(this);
   }
   
-  SourceLocation getLocation() const { return CatLoc; }
-  
   static bool classof(const Decl *D) {
     return D->getKind() == ObjcCategory;
   }
@@ -530,17 +521,15 @@
   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 @@
         ObjcMethodDecl **insMethods, unsigned numInsMembers,
         ObjcMethodDecl **clsMethods, unsigned numClsMembers);
   
-  SourceLocation getLocation() const { return Loc; }
-  
   static bool classof(const Decl *D) {
     return D->getKind() == ObjcCategoryImpl;
   }





More information about the cfe-commits mailing list