From: Fariborz Jahanian Date: Fri, 23 Dec 2011 00:31:02 +0000 (+0000) Subject: objective-c: Use class definition AST in several situations when X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=712ef874534ee1bef41d1aa4664ae36148ec8b12;p=clang objective-c: Use class definition AST in several situations when 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 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index a6f60f383e..34fd4d71e7 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -814,7 +814,9 @@ public: } void setSuperClass(ObjCInterfaceDecl * superCls) { - data().SuperClass = superCls; + data().SuperClass = + (superCls && superCls->hasDefinition()) ? superCls->getDefinition() + : superCls; } ObjCCategoryDecl* getCategoryList() const { diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 2960b13d6d..a204e45bac 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -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); } diff --git a/test/Rewriter/rewrite-super-message.mm b/test/Rewriter/rewrite-super-message.mm index 2def280834..c740137842 100644 --- a/test/Rewriter/rewrite-super-message.mm +++ b/test/Rewriter/rewrite-super-message.mm @@ -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