r302817 - PR22877: When constructing an array via a constructor with a default argument
Krzysztof Parzyszek via cfe-commits
cfe-commits at lists.llvm.org
Thu May 11 13:17:29 PDT 2017
Hexagon is still broken. :(
http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/7942
-Krzysztof
On 5/11/2017 1:58 PM, Richard Smith via cfe-commits wrote:
> Author: rsmith
> Date: Thu May 11 13:58:24 2017
> New Revision: 302817
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302817&view=rev
> Log:
> 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!
>
> Re-commit of r302750, reverted in r302776.
>
> Added:
> cfe/trunk/test/CodeGenCXX/array-default-argument.cpp
> - copied, changed from r302775, cfe/trunk/test/CodeGenCXX/array-default-argument.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=302817&r1=302816&r2=302817&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Thu May 11 13:58:24 2017
> @@ -512,12 +512,20 @@ void AggExprEmitter::EmitArrayInit(Addre
> 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 =
>
> Copied: cfe/trunk/test/CodeGenCXX/array-default-argument.cpp (from r302775, cfe/trunk/test/CodeGenCXX/array-default-argument.cpp)
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/array-default-argument.cpp?p2=cfe/trunk/test/CodeGenCXX/array-default-argument.cpp&p1=cfe/trunk/test/CodeGenCXX/array-default-argument.cpp&r1=302775&r2=302817&rev=302817&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/array-default-argument.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/array-default-argument.cpp Thu May 11 13:58:24 2017
> @@ -17,11 +17,11 @@ void g() {
> // CHECK: br label %[[LOOP:.*]]
>
> // [[LOOP]]:
> - // CHECK: {{call|invoke}}[[THISCALL:( x86_thiscallcc)?]] void @_ZN1AC1Ev([[TEMPORARY:.*]])
> + // CHECK: {{call|invoke}} {{.*}} @_ZN1AC1Ev([[TEMPORARY:.*]])
> // CHECK-EH: unwind label %[[PARTIAL_ARRAY_LPAD:.*]]
> - // CHECK: {{call|invoke}}[[THISCALL]] void @_ZN1BC1E1A({{.*}}, [[TEMPORARY]])
> + // CHECK: {{call|invoke}} {{.*}} @_ZN1BC1E1A({{.*}}, [[TEMPORARY]])
> // CHECK-EH: unwind label %[[A_AND_PARTIAL_ARRAY_LPAD:.*]]
> - // CHECK: {{call|invoke}}[[THISCALL]] void @_ZN1AD1Ev([[TEMPORARY]])
> + // CHECK: {{call|invoke}} {{.*}} @_ZN1AD1Ev([[TEMPORARY]])
> // CHECK-EH: unwind label %[[PARTIAL_ARRAY_LPAD]]
> // CHECK: getelementptr {{.*}}, i{{[0-9]*}} 1
> // CHECK: icmp eq
> @@ -32,5 +32,5 @@ void g() {
> f();
>
> // CHECK-NOT: @_ZN1AD1Ev(
> - // CHECK: {{call|invoke}}[[THISCALL]] void @_ZN1BD1Ev(
> + // CHECK: {{call|invoke}} {{.*}} @_ZN1BD1Ev(
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the cfe-commits
mailing list