Fixes a bug whereby static const block var has static
moved incorrectly. (radar 7714443).
llvm-svn: 97734
diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp
index a13bccb..a1fed8d 100644
--- a/clang/lib/Frontend/RewriteObjC.cpp
+++ b/clang/lib/Frontend/RewriteObjC.cpp
@@ -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();