Support initalisers for more than just int-typed static variables.
We now use the CodeGenModule logic for generating the constant
initialiser expression, so happily further initialiser fixes should
automatically work for statics as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44495 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGDecl.cpp b/CodeGen/CGDecl.cpp
index 09a47b9..b9f072b 100644
--- a/CodeGen/CGDecl.cpp
+++ b/CodeGen/CGDecl.cpp
@@ -75,14 +75,11 @@
llvm::Constant *Init = 0;
if (D.getInit() == 0) {
Init = llvm::Constant::getNullValue(LTy);
- } else if (D.getType()->isIntegerType()) {
- llvm::APSInt Value(static_cast<uint32_t>(
- getContext().getTypeSize(D.getInit()->getType(), SourceLocation())));
- if (D.getInit()->isIntegerConstantExpr(Value, getContext()))
- Init = llvm::ConstantInt::get(Value);
+ } else {
+ Init = CGM.EmitGlobalInit(D.getInit());
}
- assert(Init && "FIXME: Support initializers");
+ assert(Init && "Unable to create initialiser for static decl");
DMEntry =
new llvm::GlobalVariable(LTy, false,