]> granicus.if.org Git - clang/commitdiff
Fix two thinkos and add a test for importing the AST of a category
authorDouglas Gregor <dgregor@apple.com>
Wed, 8 Dec 2010 16:41:55 +0000 (16:41 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 8 Dec 2010 16:41:55 +0000 (16:41 +0000)
implementation.

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

lib/AST/ASTImporter.cpp
test/ASTMerge/Inputs/category1.m
test/ASTMerge/Inputs/category2.m
test/ASTMerge/category.m

index 7a6afbd560e1292bf4e43200f3ec49faad6a51fa..4094c88e13ba66871a935eca5f4b6d39c69414cc 100644 (file)
@@ -2834,7 +2834,8 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
   // 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 @@ Decl *ASTNodeImporter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
   }
   
   Importer.Imported(D, ToImpl);
-  ImportDeclContext(ToImpl);
+  ImportDeclContext(D);
   return ToImpl;
 }
 
index 6d4fd8d9f286c68b22abc378a84f41dddb9e0f7f..afcaab81f2b7b1c1f2ccff79a2880be7a7879417 100644 (file)
 @interface I2 (Cat3)
 @end
 
+@implementation I2 (Cat3)
+@end
+
 // Category with implementation
 @interface I2 (Cat4)
 @end
 
+@implementation I2 (Cat4)
+@end
+
+// Category with mismatched implementation
+@interface I2 (Cat6)
+@end
+
+@implementation I2 (Cat6)
+- (float)blah { return 0; }
+@end
+
index 646ebb557ab37ff6f05fa45c2461ab21da04ce5d..49a3c270a1c243745c75050551aa00cd6011de14 100644 (file)
@@ -30,6 +30,20 @@ typedef int Int;
 @interface I2 (Cat3)
 @end
 
+@implementation I2 (Cat3)
+@end
+
 // Category with implementation
 @interface I2 (Cat5)
 @end
+
+@implementation I2 (Cat5)
+@end
+
+// Category with mismatched implementation
+@interface I2 (Cat6)
+@end
+
+@implementation I2 (Cat6)
+- (int)blah { return 0; }
+@end
index 6ba229204147bf8e82872f01f78b0206349d694f..54a12408c480c28271ada6c62b791510cd1e91ee 100644 (file)
@@ -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.