diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-03-04 18:54:29 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-03-04 18:54:29 +0000 |
commit | 61b82e3ed67d9c02d8cc0a8c5976e5fb7fad12a8 (patch) | |
tree | 793a69a926d1f551b690ca75319f49785588abbc | |
parent | 6a836706c40a31c716952b74785102c90fd6afa7 (diff) |
Fixes a bug whereby static const block var has static
moved incorrectly. (radar 7714443).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97734 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Frontend/RewriteObjC.cpp | 17 | ||||
-rw-r--r-- | test/Rewriter/rewrite-static-block.mm | 11 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index a13bccbb91..a1fed8d58e 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/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/test/Rewriter/rewrite-static-block.mm b/test/Rewriter/rewrite-static-block.mm new file mode 100644 index 0000000000..c99557f52e --- /dev/null +++ b/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 |