diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-03-04 21:35:37 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-03-04 21:35:37 +0000 |
commit | 535c9c0ba2178b783a6a2e645861e318948a77a3 (patch) | |
tree | c6850ede474c0e97ec54cedf6b8d464166f78819 /clang/lib/Frontend/RewriteObjC.cpp | |
parent | a325e562eee7bf41ac9583b30a489afecfefc01d (diff) | |
download | bcm5719-llvm-535c9c0ba2178b783a6a2e645861e318948a77a3.tar.gz bcm5719-llvm-535c9c0ba2178b783a6a2e645861e318948a77a3.zip |
Patch to get around a rewriter bug rewriting storage class
on a block API struct definition.
llvm-svn: 97754
Diffstat (limited to 'clang/lib/Frontend/RewriteObjC.cpp')
-rw-r--r-- | clang/lib/Frontend/RewriteObjC.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp index a1fed8d58e5..378b4225c53 100644 --- a/clang/lib/Frontend/RewriteObjC.cpp +++ b/clang/lib/Frontend/RewriteObjC.cpp @@ -4266,6 +4266,17 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart, // Insert declaration for the function in which block literal is used. if (CurFunctionDeclToDeclareForBlock && !Blocks.empty()) RewriteBlockLiteralFunctionDecl(CurFunctionDeclToDeclareForBlock); + bool RewriteSC = (GlobalVarDecl && + !Blocks.empty() && + GlobalVarDecl->getStorageClass() == VarDecl::Static && + GlobalVarDecl->getType().getCVRQualifiers()); + if (RewriteSC) { + std::string SC(" void __"); + SC += GlobalVarDecl->getNameAsString(); + SC += "() {}"; + InsertText(FunLocStart, SC); + } + // Insert closures that were part of the function. for (unsigned i = 0, count=0; i < Blocks.size(); i++) { CollectBlockDeclRefInfo(Blocks[i]); @@ -4311,21 +4322,19 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart, BlockByCopyDeclsPtrSet.clear(); ImportedBlockDecls.clear(); } - if (GlobalVarDecl && !Blocks.empty()) { + if (RewriteSC) { // 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); + if (GlobalVarDecl->getType().isRestrictQualified()) + SC += "restrict "; + InsertText(FunLocStart, SC); } Blocks.clear(); |