diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-06-08 01:23:18 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-06-08 01:23:18 +0000 |
commit | 2659052c5d32deea3994d14f3c7d330666174a6f (patch) | |
tree | c42e56a690546a1da8ca8cabb1acf31fc51ae8b1 /lib/CodeGen/CGDecl.cpp | |
parent | 76277254fc1bfa632821d32007d04bf709d2fd39 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52084 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 5451d4afc0..e7085fb5e3 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/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(); |