]> granicus.if.org Git - clang/commitdiff
Add class and super class location info to ObjCInterfaceDecl...
authorSteve Naroff <snaroff@apple.com>
Fri, 11 Apr 2008 19:35:35 +0000 (19:35 +0000)
committerSteve Naroff <snaroff@apple.com>
Fri, 11 Apr 2008 19:35:35 +0000 (19:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49553 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
lib/Sema/Sema.cpp
lib/Sema/SemaDeclObjC.cpp

index 0efdd2e60d9ba4a0f978551d6b2d6706390b96b5..f286e2f87dc0ab7c1bf98930075d29de0557dbeb 100644 (file)
@@ -235,12 +235,15 @@ class ObjCInterfaceDecl : public NamedDecl, public DeclContext {
   bool ForwardDecl:1; // declared with @class.
   bool InternalInterface:1; // true - no @interface for @implementation
   
+  SourceLocation ClassLoc; // location of the class identifier.
+  SourceLocation SuperClassLoc; // location of the super class identifier.
   SourceLocation EndLoc; // marks the '>', '}', or identifier.
   SourceLocation AtEndLoc; // marks the end of the entire interface.
 
   ObjCInterfaceDecl(SourceLocation atLoc,
                     unsigned numRefProtos,
-                    IdentifierInfo *Id, bool FD, bool isInternal)
+                    IdentifierInfo *Id, SourceLocation CLoc,
+                    bool FD, bool isInternal)
     : NamedDecl(ObjCInterface, atLoc, Id), DeclContext(ObjCInterface),
       TypeForDecl(0), SuperClass(0),
       ReferencedProtocols(0), NumReferencedProtocols(0), Ivars(0), 
@@ -248,14 +251,17 @@ class ObjCInterfaceDecl : public NamedDecl, public DeclContext {
       InstanceMethods(0), NumInstanceMethods(0), 
       ClassMethods(0), NumClassMethods(0),
       CategoryList(0), PropertyDecl(0), NumPropertyDecl(0),
-      ForwardDecl(FD), InternalInterface(isInternal) {
+      ForwardDecl(FD), InternalInterface(isInternal),
+      ClassLoc(CLoc) {
         AllocIntfRefProtocols(numRefProtos);
       }
 public:
 
   static ObjCInterfaceDecl *Create(ASTContext &C,
                                    SourceLocation atLoc,
-                                   unsigned numRefProtos, IdentifierInfo *Id,
+                                   unsigned numRefProtos, 
+                                   IdentifierInfo *Id, 
+                                   SourceLocation ClassLoc = SourceLocation(),
                                    bool ForwardDecl = false,
                                    bool isInternal = false);
   
@@ -363,6 +369,10 @@ public:
   SourceLocation getLocEnd() const { return EndLoc; }
   void setLocEnd(SourceLocation LE) { EndLoc = LE; };
   
+  SourceLocation getClassLoc() const { return ClassLoc; }
+  void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; }
+  SourceLocation getSuperClassLoc() const { return SuperClassLoc; }
+  
   // We also need to record the @end location.
   SourceLocation getAtEndLoc() const { return AtEndLoc; }
   
index 8126485c4ff89b6e4ad583b8c4d2bdc120520cba..0b73ca5b5783bc1a9a4df217d4df2fba8fbc3dc1 100644 (file)
@@ -37,11 +37,12 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
 ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
                                              SourceLocation atLoc,
                                              unsigned numRefProtos,
-                                             IdentifierInfo *Id,
+                                             IdentifierInfo *Id, 
+                                             SourceLocation ClassLoc,
                                              bool ForwardDecl, bool isInternal){
   void *Mem = C.getAllocator().Allocate<ObjCInterfaceDecl>();
   return new (Mem) ObjCInterfaceDecl(atLoc, numRefProtos,
-                                     Id, ForwardDecl,
+                                     Id, ClassLoc, ForwardDecl,
                                      isInternal);
 }
 
index a0d4ff799567cbd395f1aa3d53d42834fc770133..92858726b483e0f8e8b1d5414f322d69038d0c25 100644 (file)
@@ -112,7 +112,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
     // Synthesize "@class Protocol;
     ObjCInterfaceDecl *ProtocolDecl =
       ObjCInterfaceDecl::Create(Context, SourceLocation(), 0, 
-                                &Context.Idents.get("Protocol"), true);
+                                &Context.Idents.get("Protocol"), 
+                                SourceLocation(), true);
     Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl));
     
     // Synthesize "typedef struct objc_object { Class isa; } *id;"
index 127645044c3df2939dcb504a4682b907b60a39fa..776a50f6f2ac8a317a037f13043cc61196a03a9c 100644 (file)
@@ -98,7 +98,7 @@ Sema::DeclTy *Sema::ActOnStartClassInterface(
   }
   else {
     IDecl = ObjCInterfaceDecl::Create(Context, AtInterfaceLoc, NumProtocols,
-                                      ClassName);
+                                      ClassName, ClassLoc);
   
     ObjCInterfaceDecls[ClassName] = IDecl;
     // Remember that this needs to be removed when the scope is popped.
@@ -126,6 +126,7 @@ Sema::DeclTy *Sema::ActOnStartClassInterface(
       }
     }
     IDecl->setSuperClass(SuperClassEntry);
+    IDecl->setSuperClassLoc(SuperLoc);
     IDecl->setLocEnd(SuperLoc);
   } else { // we have a root class.
     IDecl->setLocEnd(ClassLoc);
@@ -383,7 +384,7 @@ Sema::DeclTy *Sema::ActOnStartClassImplementation(
     // Legacy case of @implementation with no corresponding @interface.
     // Build, chain & install the interface decl into the identifier.
     IDecl = ObjCInterfaceDecl::Create(Context, AtClassImplLoc, 0, ClassName, 
-                                      false, true);
+                                      ClassLoc, false, true);
     ObjCInterfaceDecls[ClassName] = IDecl;
     IDecl->setSuperClass(SDecl);
     IDecl->setLocEnd(ClassLoc);
@@ -591,7 +592,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
     ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); 
     if (!IDecl) {  // Not already seen?  Make a forward decl.
       IDecl = ObjCInterfaceDecl::Create(Context, AtClassLoc, 0, IdentList[i],
-                                        true);
+                                        SourceLocation(), true);
       ObjCInterfaceDecls[IdentList[i]] = IDecl;
 
       // Remember that this needs to be removed when the scope is popped.