[cfe-commits] r121263 - in /cfe/trunk: lib/AST/ASTImporter.cpp test/ASTMerge/Inputs/category1.m test/ASTMerge/Inputs/category2.m test/ASTMerge/category.m

Douglas Gregor dgregor at apple.com
Wed Dec 8 08:41:55 PST 2010


Author: dgregor
Date: Wed Dec  8 10:41:55 2010
New Revision: 121263

URL: http://llvm.org/viewvc/llvm-project?rev=121263&view=rev
Log:
Fix two thinkos and add a test for importing the AST of a category
implementation.

Modified:
    cfe/trunk/lib/AST/ASTImporter.cpp
    cfe/trunk/test/ASTMerge/Inputs/category1.m
    cfe/trunk/test/ASTMerge/Inputs/category2.m
    cfe/trunk/test/ASTMerge/category.m

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=121263&r1=121262&r2=121263&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Dec  8 10:41:55 2010
@@ -2834,7 +2834,8 @@
   // If we have an implementation, import it as well.
   if (D->getImplementation()) {
     ObjCCategoryImplDecl *Impl
-      = cast<ObjCCategoryImplDecl>(Importer.Import(D->getImplementation()));
+      = cast_or_null<ObjCCategoryImplDecl>(
+                                       Importer.Import(D->getImplementation()));
     if (!Impl)
       return 0;
     
@@ -3057,7 +3058,7 @@
   }
   
   Importer.Imported(D, ToImpl);
-  ImportDeclContext(ToImpl);
+  ImportDeclContext(D);
   return ToImpl;
 }
 

Modified: cfe/trunk/test/ASTMerge/Inputs/category1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/category1.m?rev=121263&r1=121262&r2=121263&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/Inputs/category1.m (original)
+++ cfe/trunk/test/ASTMerge/Inputs/category1.m Wed Dec  8 10:41:55 2010
@@ -28,7 +28,21 @@
 @interface I2 (Cat3)
 @end
 
+ at implementation I2 (Cat3)
+ at end
+
 // Category with implementation
 @interface I2 (Cat4)
 @end
 
+ at implementation I2 (Cat4)
+ at end
+
+// Category with mismatched implementation
+ at interface I2 (Cat6)
+ at end
+
+ at implementation I2 (Cat6)
+- (float)blah { return 0; }
+ at end
+

Modified: cfe/trunk/test/ASTMerge/Inputs/category2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/category2.m?rev=121263&r1=121262&r2=121263&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/Inputs/category2.m (original)
+++ cfe/trunk/test/ASTMerge/Inputs/category2.m Wed Dec  8 10:41:55 2010
@@ -30,6 +30,20 @@
 @interface I2 (Cat3)
 @end
 
+ at implementation I2 (Cat3)
+ at end
+
 // Category with implementation
 @interface I2 (Cat5)
 @end
+
+ at implementation I2 (Cat5)
+ at end
+
+// Category with mismatched implementation
+ at interface I2 (Cat6)
+ at end
+
+ at implementation I2 (Cat6)
+- (int)blah { return 0; }
+ at end

Modified: cfe/trunk/test/ASTMerge/category.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/category.m?rev=121263&r1=121262&r2=121263&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/category.m (original)
+++ cfe/trunk/test/ASTMerge/category.m Wed Dec  8 10:41:55 2010
@@ -6,4 +6,6 @@
 // CHECK: category1.m:16:1: note: instance method 'method2' also declared here
 // CHECK: category2.m:26:1: error: instance method 'method3' has incompatible result types in different translation units ('float' vs. 'int')
 // CHECK: category1.m:24:1: note: instance method 'method3' also declared here
-// CHECK: 2 errors generated.
+// CHECK: category2.m:48:1: error: instance method 'blah' has incompatible result types in different translation units ('int' vs. 'float')
+// CHECK: category1.m:46:1: note: instance method 'blah' also declared here
+// CHECK: 3 errors generated.





More information about the cfe-commits mailing list