summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-08-08 23:24:23 +0000
committerAnders Carlsson <andersca@mac.com>2009-08-08 23:24:23 +0000
commitb8be93fc92c684a331a1ad40b30c77de3c18a67a (patch)
treef27bb74a30944cd5ce4ab45f693f6cf96e84e7e3 /clang/lib/CodeGen/CodeGenModule.cpp
parentcfed3005e5c9d8ff26ee53ef4f9e459a2106c11d (diff)
downloadbcm5719-llvm-b8be93fc92c684a331a1ad40b30c77de3c18a67a.tar.gz
bcm5719-llvm-b8be93fc92c684a331a1ad40b30c77de3c18a67a.zip
Add support for global initializers.
llvm-svn: 78515
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 503bcda8e7b..df9b341ac9b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -62,6 +62,9 @@ CodeGenModule::~CodeGenModule() {
}
void CodeGenModule::Release() {
+ // We need to call this first because it can add deferred declarations.
+ EmitCXXGlobalInitFunc();
+
EmitDeferred();
if (Runtime)
if (llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction())
@@ -854,10 +857,16 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
Init = EmitNullConstant(D->getType());
} else {
Init = EmitConstantExpr(D->getInit(), D->getType());
+
if (!Init) {
- ErrorUnsupported(D, "static initializer");
QualType T = D->getInit()->getType();
- Init = llvm::UndefValue::get(getTypes().ConvertType(T));
+ if (getLangOptions().CPlusPlus) {
+ CXXGlobalInits.push_back(D);
+ Init = EmitNullConstant(T);
+ } else {
+ ErrorUnsupported(D, "static initializer");
+ Init = llvm::UndefValue::get(getTypes().ConvertType(T));
+ }
}
}
OpenPOWER on IntegriCloud