]> granicus.if.org Git - clang/commitdiff
modern objective-c translator. ifdef'out
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 12 Apr 2012 16:33:31 +0000 (16:33 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 12 Apr 2012 16:33:31 +0000 (16:33 +0000)
__weak and __block when rewriting.
// rdar://11236342

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154592 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Rewrite/RewriteModernObjC.cpp
test/Rewriter/rewrite-modern-block.mm

index fd621a2a5ccb67dca13bcb15a7422570a7401cc1..ba62ad3c4140fd987faa5e05c6cc3ad63f98c639 100644 (file)
@@ -5726,7 +5726,12 @@ void RewriteModernObjC::Initialize(ASTContext &context) {
     Preamble += "#ifndef KEEP_ATTRIBUTES\n";  // We use this for clang tests.
     Preamble += "#define __attribute__(X)\n";
     Preamble += "#endif\n";
+    Preamble += "#ifndef __weak\n";
     Preamble += "#define __weak\n";
+    Preamble += "#endif\n";
+    Preamble += "#ifndef __block\n";
+    Preamble += "#define __block\n";
+    Preamble += "#endif\n";
   }
   else {
     Preamble += "#define __block\n";
index c5231bfcebc61deb4b15149de596ccf9f17c8f0c..8da723d319ffc7e25bc3faaa777fcac41ccf3b00 100644 (file)
@@ -1,5 +1,5 @@
 // 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
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
 // rdar://11230308
 
 typedef struct {
@@ -16,3 +16,8 @@ void y() {
         x(&bytes);
     };
 }
+
+// rdar://11236342
+int foo() {
+    __block int hello;
+}