[cfe-commits] r147210 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp test/Rewriter/rewrite-super-message.mm

Fariborz Jahanian fjahanian at apple.com
Thu Dec 22 16:31:03 PST 2011


Author: fjahanian
Date: Thu Dec 22 18:31:02 2011
New Revision: 147210

URL: http://llvm.org/viewvc/llvm-project?rev=147210&view=rev
Log:
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.


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

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=147210&r1=147209&r2=147210&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Dec 22 18:31:02 2011
@@ -814,7 +814,9 @@
   }
 
   void setSuperClass(ObjCInterfaceDecl * superCls) { 
-    data().SuperClass = superCls; 
+    data().SuperClass = 
+      (superCls && superCls->hasDefinition()) ? superCls->getDefinition() 
+                                              : superCls; 
   }
 
   ObjCCategoryDecl* getCategoryList() const {

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=147210&r1=147209&r2=147210&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Dec 22 18:31:02 2011
@@ -1112,6 +1112,8 @@
                              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 @@
                                ObjCInterfaceDecl *SuperDecl,
                                SourceLocation nameLoc,
                                SourceLocation atStartLoc) {
+  if (ClassInterface && ClassInterface->hasDefinition())
+    ClassInterface = ClassInterface->getDefinition();
   return new (C) ObjCImplementationDecl(DC, ClassInterface, SuperDecl,
                                         nameLoc, atStartLoc);
 }

Modified: cfe/trunk/test/Rewriter/rewrite-super-message.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-super-message.mm?rev=147210&r1=147209&r2=147210&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-super-message.mm (original)
+++ cfe/trunk/test/Rewriter/rewrite-super-message.mm Thu Dec 22 18:31:02 2011
@@ -36,3 +36,16 @@
     return [super allocWithZone:zone];
 }
 @end
+
+ at interface XNSArray
+{
+  Class isa;
+}
+ at end
+
+ at class XNSArray;
+
+ at interface __NSArray0 : XNSArray
+ at end
+
+ at implementation __NSArray0 @end





More information about the cfe-commits mailing list