summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-10-07 19:54:22 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-10-07 19:54:22 +0000
commitd29406233b051f3dcc9dc5316d204401016bef6b (patch)
treeb37be5a3c115cf446706831ce404edb5880741d7
parent5a78755336ba7296568423d68d45d4b57aae8080 (diff)
downloadbcm5719-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.cpp15
-rw-r--r--clang/test/Rewriter/rewrite-interface-locals.mm20
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
OpenPOWER on IntegriCloud