summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-06-08 01:23:18 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-06-08 01:23:18 +0000
commitc98a7add43b61ec7d0e87ec2b1f30596af6515d0 (patch)
treeb49c6f73ebb8c1dd6a7574fa73b0b58a314a1d21 /clang/lib/CodeGen/CGDecl.cpp
parent69d721e07144a9808304709cc7b4ef216a70ebb1 (diff)
downloadbcm5719-llvm-c98a7add43b61ec7d0e87ec2b1f30596af6515d0.tar.gz
bcm5719-llvm-c98a7add43b61ec7d0e87ec2b1f30596af6515d0.zip
Don't crash emitting an initializer for a static local with union type.
This fix just makes sure to construct the global with the appropriate type, and fixes up the one user this affects to compensate. llvm-svn: 52084
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 5451d4afc02..e7085fb5e31 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -93,8 +93,9 @@ CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D,
else
assert(0 && "Unknown context for block var decl"); // FIXME Handle objc.
- llvm::GlobalValue *GV =
- new llvm::GlobalVariable(LTy, false, llvm::GlobalValue::InternalLinkage,
+ llvm::GlobalValue *GV =
+ new llvm::GlobalVariable(Init->getType(), false,
+ llvm::GlobalValue::InternalLinkage,
Init, ContextName + Separator + D.getName(),
&CGM.getModule(), 0, Ty.getAddressSpace());
@@ -115,7 +116,10 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
CGM.AddAnnotation(Ann);
}
- DMEntry = GV;
+ const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(D.getType());
+ const llvm::Type *LPtrTy =
+ llvm::PointerType::get(LTy, D.getType().getAddressSpace());
+ DMEntry = llvm::ConstantExpr::getBitCast(GV, LPtrTy);
// Emit global variable debug descriptor for static vars.
CGDebugInfo *DI = CGM.getDebugInfo();
OpenPOWER on IntegriCloud