From cad2c59b0c087edea83d0fbf6eabde4a7960c778 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 8 Dec 2010 16:41:55 +0000 Subject: [PATCH] Fix two thinkos and add a test for importing the AST of a category implementation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121263 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTImporter.cpp | 5 +++-- test/ASTMerge/Inputs/category1.m | 14 ++++++++++++++ test/ASTMerge/Inputs/category2.m | 14 ++++++++++++++ test/ASTMerge/category.m | 4 +++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 7a6afbd560..4094c88e13 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2834,7 +2834,8 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { // If we have an implementation, import it as well. if (D->getImplementation()) { ObjCCategoryImplDecl *Impl - = cast(Importer.Import(D->getImplementation())); + = cast_or_null( + 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; } diff --git a/test/ASTMerge/Inputs/category1.m b/test/ASTMerge/Inputs/category1.m index 6d4fd8d9f2..afcaab81f2 100644 --- a/test/ASTMerge/Inputs/category1.m +++ b/test/ASTMerge/Inputs/category1.m @@ -28,7 +28,21 @@ @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 + diff --git a/test/ASTMerge/Inputs/category2.m b/test/ASTMerge/Inputs/category2.m index 646ebb557a..49a3c270a1 100644 --- a/test/ASTMerge/Inputs/category2.m +++ b/test/ASTMerge/Inputs/category2.m @@ -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 diff --git a/test/ASTMerge/category.m b/test/ASTMerge/category.m index 6ba2292041..54a12408c4 100644 --- a/test/ASTMerge/category.m +++ b/test/ASTMerge/category.m @@ -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. -- 2.40.0