diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index db609f62453..5b372faef71 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -543,10 +543,15 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) { // Static data may be deferred, but out-of-line static data members // cannot be. - // FIXME: What if the initializer has side effects? - return VD->isInAnonymousNamespace() || - (VD->getStorageClass() == VarDecl::Static && - !(VD->isStaticDataMember() && VD->isOutOfLine())); + if (VD->isInAnonymousNamespace()) + return true; + if (VD->getStorageClass() == VarDecl::Static) { + // Initializer has side effects? + if (VD->getInit() && VD->getInit()->HasSideEffects(Context)) + return false; + return !(VD->isStaticDataMember() && VD->isOutOfLine()); + } + return false; } void CodeGenModule::EmitGlobal(GlobalDecl GD) { diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 2e58337ee52..b09f52cf2bf 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -499,7 +499,7 @@ private: /// EmitCXXGlobalInitFunc - Emit a function that initializes C++ globals. void EmitCXXGlobalInitFunc(); - + // FIXME: Hardcoding priority here is gross. void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535); void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535); |