From d29406233b051f3dcc9dc5316d204401016bef6b Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 7 Oct 2013 19:54:22 +0000 Subject: [PATCH] ObjectiveC modern rewriter. Rewrite typedefs declared locally in ObjectiveC containers. // rdar://15143875 llvm-svn: 192127 --- .../Rewrite/Frontend/RewriteModernObjC.cpp | 15 ++++++++++++++ .../test/Rewriter/rewrite-interface-locals.mm | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 clang/test/Rewriter/rewrite-interface-locals.mm diff --git a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp index af9cda3faddf..ae33ac816e3d 100644 --- a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp +++ b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp @@ -221,6 +221,21 @@ namespace { } return true; } + + virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) { + for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) { + if (TypedefNameDecl *TD = dyn_cast(*I)) { + if (isTopLevelBlockPointerType(TD->getUnderlyingType())) + RewriteBlockPointerDecl(TD); + else if (TD->getUnderlyingType()->isFunctionPointerType()) + CheckFunctionPointerDecl(TD->getUnderlyingType(), TD); + else + RewriteObjCQualifiedInterfaceTypes(TD); + } + } + return; + } + void HandleTopLevelSingleDecl(Decl *D); void HandleDeclInMainFile(Decl *D); RewriteModernObjC(std::string inFile, raw_ostream *OS, diff --git a/clang/test/Rewriter/rewrite-interface-locals.mm b/clang/test/Rewriter/rewrite-interface-locals.mm new file mode 100644 index 000000000000..ef361051c198 --- /dev/null +++ b/clang/test/Rewriter/rewrite-interface-locals.mm @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar://15143875 + +@class NSData, NSError; + +@interface Foo + +typedef void (^Callback)(NSData *data, NSError *error); + +- (void)doSomething:(NSData *)data callback:(Callback)callback; +@end + +@implementation Foo + +- (void)doSomething:(NSData *)data callback:(Callback)callback { + callback(0, 0); +} + +@end