diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-22 22:48:32 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-22 22:48:32 +0000 |
| commit | 7401cf524cdb7aad4951d8727d280f8b271af5a2 (patch) | |
| tree | 284aeb93e42fdfb64ef3bb150e36b27196c8c253 /lib/CodeGen/CGExpr.cpp | |
| parent | 6300f5b4382d5128c9346a4d4f05e7bac2e3d771 (diff) | |
| download | clang-7401cf524cdb7aad4951d8727d280f8b271af5a2.tar.gz clang-7401cf524cdb7aad4951d8727d280f8b271af5a2.tar.bz2 clang-7401cf524cdb7aad4951d8727d280f8b271af5a2.tar.xz | |
Use static storage duration for file-scope compound literals, even when they
appear in non-constant initializers in C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145087 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index a35bb5f711..e4f81b7a3f 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1947,6 +1947,11 @@ CodeGenFunction::EmitLValueForFieldInitialization(llvm::Value *BaseValue, } LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr *E){ + if (E->isFileScope()) { + llvm::Value *GlobalPtr = CGM.GetAddrOfConstantCompoundLiteral(E); + return MakeAddrLValue(GlobalPtr, E->getType()); + } + llvm::Value *DeclPtr = CreateMemTemp(E->getType(), ".compoundliteral"); const Expr *InitExpr = E->getInitializer(); LValue Result = MakeAddrLValue(DeclPtr, E->getType()); |
