[cfe-commits] r97734 - in /cfe/trunk: lib/Frontend/RewriteObjC.cpp test/Rewriter/rewrite-static-block.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Mar 4 10:54:29 PST 2010
Author: fjahanian
Date: Thu Mar 4 12:54:29 2010
New Revision: 97734
URL: http://llvm.org/viewvc/llvm-project?rev=97734&view=rev
Log:
Fixes a bug whereby static const block var has static
moved incorrectly. (radar 7714443).
Added:
cfe/trunk/test/Rewriter/rewrite-static-block.mm
Modified:
cfe/trunk/lib/Frontend/RewriteObjC.cpp
Modified: cfe/trunk/lib/Frontend/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteObjC.cpp?rev=97734&r1=97733&r2=97734&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/RewriteObjC.cpp Thu Mar 4 12:54:29 2010
@@ -4311,6 +4311,23 @@
BlockByCopyDeclsPtrSet.clear();
ImportedBlockDecls.clear();
}
+ if (GlobalVarDecl && !Blocks.empty()) {
+ // Must insert any 'const/volatile/static here. Since it has been
+ // removed as result of rewriting of block literals.
+ // FIXME. We add as we need.
+ std::string SC;
+ if (GlobalVarDecl->getStorageClass() == VarDecl::Static)
+ SC = "static ";
+ if (GlobalVarDecl->getStorageClass() == VarDecl::Extern)
+ SC = "extern ";
+ if (GlobalVarDecl->getType().isConstQualified())
+ SC += "const ";
+ if (GlobalVarDecl->getType().isVolatileQualified())
+ SC += "volatile ";
+ if (!SC.empty())
+ InsertText(FunLocStart, SC);
+ }
+
Blocks.clear();
InnerDeclRefsCount.clear();
InnerDeclRefs.clear();
Added: cfe/trunk/test/Rewriter/rewrite-static-block.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-static-block.mm?rev=97734&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-static-block.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-static-block.mm Thu Mar 4 12:54:29 2010
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp -emit-llvm -o %t-rw.ll
+// RUN: FileCheck --input-file=%t-rw.ll %s
+
+typedef void (^void_block_t)(void);
+
+static const void_block_t myblock = ^{
+
+};
+
+// CHECK: myblock = internal global
More information about the cfe-commits
mailing list