summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-05-11 00:17:17 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-05-11 00:17:17 +0000
commit97a2cdbff3df10f032f99bf3306fd5dd2c5d4cd1 (patch)
tree93ee0eeb793051c3c84e38707520515535d8eeb9 /clang/lib/CodeGen
parentbfb8e189d224c7bc9764d5512f4342c546da31b1 (diff)
downloadbcm5719-llvm-97a2cdbff3df10f032f99bf3306fd5dd2c5d4cd1.tar.gz
bcm5719-llvm-97a2cdbff3df10f032f99bf3306fd5dd2c5d4cd1.zip
PR22877: When constructing an array via a constructor with a default argument
in list-initialization, run cleanups for the default argument after each iteration of the initialization loop. We previously only ran the destructor for any temporary once, at the end of the complete loop, rather than once per iteration! llvm-svn: 302750
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 49bbb4808ea..a05a088f091 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -512,12 +512,20 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType,
currentElement->addIncoming(element, entryBB);
// Emit the actual filler expression.
- LValue elementLV =
- CGF.MakeAddrLValue(Address(currentElement, elementAlign), elementType);
- if (filler)
- EmitInitializationToLValue(filler, elementLV);
- else
- EmitNullInitializationToLValue(elementLV);
+ {
+ // C++1z [class.temporary]p5:
+ // when a default constructor is called to initialize an element of
+ // an array with no corresponding initializer [...] the destruction of
+ // every temporary created in a default argument is sequenced before
+ // the construction of the next array element, if any
+ CodeGenFunction::RunCleanupsScope CleanupsScope(CGF);
+ LValue elementLV =
+ CGF.MakeAddrLValue(Address(currentElement, elementAlign), elementType);
+ if (filler)
+ EmitInitializationToLValue(filler, elementLV);
+ else
+ EmitNullInitializationToLValue(elementLV);
+ }
// Move on to the next element.
llvm::Value *nextElement =
OpenPOWER on IntegriCloud