]> granicus.if.org Git - clang/commitdiff
objective-c: Use class definition AST in several situations when
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 23 Dec 2011 00:31:02 +0000 (00:31 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 23 Dec 2011 00:31:02 +0000 (00:31 +0000)
building related objc ASTs which require a class definition AST.
These were uncovered when testing objc rewriter.

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

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
test/Rewriter/rewrite-super-message.mm

index a6f60f383ec4671c21badfaa10362f5559713561..34fd4d71e732df5c3283056ffcfd2484428dab39 100644 (file)
@@ -814,7 +814,9 @@ public:
   }
 
   void setSuperClass(ObjCInterfaceDecl * superCls) { 
-    data().SuperClass = superCls; 
+    data().SuperClass = 
+      (superCls && superCls->hasDefinition()) ? superCls->getDefinition() 
+                                              : superCls; 
   }
 
   ObjCCategoryDecl* getCategoryList() const {
index 2960b13d6de26f161ee9755950f4783ea7cc5c4d..a204e45bac9fd658726a7a492838b65bdd1019c6 100644 (file)
@@ -1112,6 +1112,8 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
                              SourceLocation nameLoc,
                              SourceLocation atStartLoc,
                              SourceLocation CategoryNameLoc) {
+  if (ClassInterface && ClassInterface->hasDefinition())
+    ClassInterface = ClassInterface->getDefinition();
   return new (C) ObjCCategoryImplDecl(DC, Id, ClassInterface,
                                       nameLoc, atStartLoc, CategoryNameLoc);
 }
@@ -1196,6 +1198,8 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
                                ObjCInterfaceDecl *SuperDecl,
                                SourceLocation nameLoc,
                                SourceLocation atStartLoc) {
+  if (ClassInterface && ClassInterface->hasDefinition())
+    ClassInterface = ClassInterface->getDefinition();
   return new (C) ObjCImplementationDecl(DC, ClassInterface, SuperDecl,
                                         nameLoc, atStartLoc);
 }
index 2def2808346f8efec4299589896b20cb8f0939be..c7401378422ad825c8f37d79ecd90f44fc232ce1 100644 (file)
@@ -36,3 +36,16 @@ void *sel_registerName(const char *);
     return [super allocWithZone:zone];
 }
 @end
+
+@interface XNSArray
+{
+  Class isa;
+}
+@end
+
+@class XNSArray;
+
+@interface __NSArray0 : XNSArray
+@end
+
+@implementation __NSArray0 @end