r192127 - ObjectiveC modern rewriter. Rewrite typedefs
Fariborz Jahanian
fjahanian at apple.com
Mon Oct 7 12:54:22 PDT 2013
Author: fjahanian
Date: Mon Oct 7 14:54:22 2013
New Revision: 192127
URL: http://llvm.org/viewvc/llvm-project?rev=192127&view=rev
Log:
ObjectiveC modern rewriter. Rewrite typedefs
declared locally in ObjectiveC containers.
// rdar://15143875
Added:
cfe/trunk/test/Rewriter/rewrite-interface-locals.mm
Modified:
cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
Modified: cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp?rev=192127&r1=192126&r2=192127&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp Mon Oct 7 14:54:22 2013
@@ -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,
Added: cfe/trunk/test/Rewriter/rewrite-interface-locals.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-interface-locals.mm?rev=192127&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-interface-locals.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-interface-locals.mm Mon Oct 7 14:54:22 2013
@@ -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
+
+ at class NSData, NSError;
+
+ at interface Foo
+
+typedef void (^Callback)(NSData *data, NSError *error);
+
+- (void)doSomething:(NSData *)data callback:(Callback)callback;
+ at end
+
+ at implementation Foo
+
+- (void)doSomething:(NSData *)data callback:(Callback)callback {
+ callback(0, 0);
+}
+
+ at end
More information about the cfe-commits
mailing list