From b2b5d02cdcb0d7eabf61aad6dd46d81f5476c944 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 17 Dec 2013 01:01:33 +0000 Subject: [PATCH] ObjectiveC migrator. Fixes a bug when protocol conformance is inferred. // rdar://15515206 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197448 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/ObjCMT.cpp | 4 +++- test/ARCMT/objcmt-protocol-conformance.m | 16 ++++++++++++++++ test/ARCMT/objcmt-protocol-conformance.m.result | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index cd0d01957e..e12df0582f 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -756,6 +756,8 @@ void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx, if (!DropIt) MinimalConformingProtocols.push_back(TargetPDecl); } + if (MinimalConformingProtocols.empty()) + return; edit::Commit commit(*Editor); rewriteToObjCInterfaceDecl(IDecl, MinimalConformingProtocols, *NSAPIObj, commit); @@ -1765,7 +1767,7 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { migrateObjCInterfaceDecl(Ctx, CatDecl); } else if (ObjCProtocolDecl *PDecl = dyn_cast(*D)) - ObjCProtocolDecls.insert(PDecl); + ObjCProtocolDecls.insert(PDecl->getCanonicalDecl()); else if (const ObjCImplementationDecl *ImpDecl = dyn_cast(*D)) { if ((ASTMigrateActions & FrontendOptions::ObjCMT_ProtocolConformance) && diff --git a/test/ARCMT/objcmt-protocol-conformance.m b/test/ARCMT/objcmt-protocol-conformance.m index 7bc7d93817..f4c8f5112a 100644 --- a/test/ARCMT/objcmt-protocol-conformance.m +++ b/test/ARCMT/objcmt-protocol-conformance.m @@ -112,3 +112,19 @@ @implementation Test7 @end +// rdar://15515206 +@interface BTLEBrowser +@end + +@protocol CBCentralManagerDelegate; + +@protocol CBCentralManagerDelegate +- (id) Meth1: (double) arg; +@end + +@interface BTLEBrowser() +@end + +@implementation BTLEBrowser +- (id) Meth15515206: (double) arg { return 0; } +@end diff --git a/test/ARCMT/objcmt-protocol-conformance.m.result b/test/ARCMT/objcmt-protocol-conformance.m.result index dc0874c88f..0322ab81d6 100644 --- a/test/ARCMT/objcmt-protocol-conformance.m.result +++ b/test/ARCMT/objcmt-protocol-conformance.m.result @@ -112,3 +112,19 @@ @implementation Test7 @end +// rdar://15515206 +@interface BTLEBrowser +@end + +@protocol CBCentralManagerDelegate; + +@protocol CBCentralManagerDelegate +- (id) Meth1: (double) arg; +@end + +@interface BTLEBrowser() +@end + +@implementation BTLEBrowser +- (id) Meth15515206: (double) arg { return 0; } +@end -- 2.40.0