summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-09-07 23:26:17 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-09-07 23:26:17 +0000
commit366a94822bf210cbb5d32a76b63e8423268565db (patch)
tree74d9fffd4baacf1929d943159a112bb0030b7f52 /clang/lib/CodeGen
parenta4d9c78aa1689e86961c96b7a7feaa67d83373ba (diff)
downloadbcm5719-llvm-366a94822bf210cbb5d32a76b63e8423268565db.tar.gz
bcm5719-llvm-366a94822bf210cbb5d32a76b63e8423268565db.zip
Local static block variable referecned in its
block-literal initializer expression causes IRgen to crash. This patch fixes by saving it in StaticLocalDecl map already used for such purposes. (radar 8390455). llvm-svn: 113307
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp7
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp3
2 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 57e5236c67e..97c03410871 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -244,6 +244,10 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D,
// Make sure to evaluate VLA bounds now so that we have them for later.
if (D.getType()->isVariablyModifiedType())
EmitVLASize(D.getType());
+
+ // Local static block variables must be treated as globals as they may be
+ // referenced in their RHS initializer block-literal expresion.
+ CGM.setStaticLocalDeclAddress(&D, GV);
// If this value has an initializer, emit it.
if (D.getInit())
@@ -266,9 +270,6 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D,
if (D.hasAttr<UsedAttr>())
CGM.AddUsedGlobal(GV);
- if (getContext().getLangOptions().CPlusPlus)
- CGM.setStaticLocalDeclAddress(&D, GV);
-
// We may have to cast the constant because of the initializer
// mismatch above.
//
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index dacc04f5997..bb0462f9635 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1152,8 +1152,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
bool NonGCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>();
llvm::Value *V = LocalDeclMap[VD];
- if (!V && getContext().getLangOptions().CPlusPlus &&
- VD->isStaticLocal())
+ if (!V && VD->isStaticLocal())
V = CGM.getStaticLocalDeclAddress(VD);
assert(V && "DeclRefExpr not entered in LocalDeclMap?");
OpenPOWER on IntegriCloud