summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-03-04 18:54:29 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-03-04 18:54:29 +0000
commit8bb35c4d7c0425c51ef068dcb254cfafd4f0acb1 (patch)
treee0157e692eb05be8a3ed260201e3a0e6eb65aa0f /clang
parent2e42fec3a092692a98865cb264940e9320c42aa0 (diff)
downloadbcm5719-llvm-8bb35c4d7c0425c51ef068dcb254cfafd4f0acb1.tar.gz
bcm5719-llvm-8bb35c4d7c0425c51ef068dcb254cfafd4f0acb1.zip
Fixes a bug whereby static const block var has static
moved incorrectly. (radar 7714443). llvm-svn: 97734
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Frontend/RewriteObjC.cpp17
-rw-r--r--clang/test/Rewriter/rewrite-static-block.mm11
2 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp
index a13bccbb91e..a1fed8d58e5 100644
--- a/clang/lib/Frontend/RewriteObjC.cpp
+++ b/clang/lib/Frontend/RewriteObjC.cpp
@@ -4311,6 +4311,23 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
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();
diff --git a/clang/test/Rewriter/rewrite-static-block.mm b/clang/test/Rewriter/rewrite-static-block.mm
new file mode 100644
index 00000000000..c99557f52ef
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-static-block.mm
@@ -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
OpenPOWER on IntegriCloud