diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2013-10-07 19:54:22 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-10-07 19:54:22 +0000 |
| commit | d29406233b051f3dcc9dc5316d204401016bef6b (patch) | |
| tree | b37be5a3c115cf446706831ce404edb5880741d7 | |
| parent | 5a78755336ba7296568423d68d45d4b57aae8080 (diff) | |
| download | bcm5719-llvm-d29406233b051f3dcc9dc5316d204401016bef6b.tar.gz bcm5719-llvm-d29406233b051f3dcc9dc5316d204401016bef6b.zip | |
ObjectiveC modern rewriter. Rewrite typedefs
declared locally in ObjectiveC containers.
// rdar://15143875
llvm-svn: 192127
| -rw-r--r-- | clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp | 15 | ||||
| -rw-r--r-- | clang/test/Rewriter/rewrite-interface-locals.mm | 20 |
2 files changed, 35 insertions, 0 deletions
diff --git a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp index af9cda3fadd..ae33ac816e3 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<TypedefNameDecl>(*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 00000000000..ef361051c19 --- /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 |

