diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-05 18:03:03 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-05 18:03:03 +0000 |
commit | 4127b8ef97e5d361fddf9142af61cee106348522 (patch) | |
tree | a9f1d4e8aa5f4dca04d8357867a0e73d7712fe00 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | a117dd23e9eb9ac77eca31de963dc8ba51aef204 (diff) | |
download | bcm5719-llvm-4127b8ef97e5d361fddf9142af61cee106348522.tar.gz bcm5719-llvm-4127b8ef97e5d361fddf9142af61cee106348522.zip |
Added support for static variables which require
initialization before main. Fixes pr5396.
llvm-svn: 86145
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 9 insertions, 4 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) { |