r182969 - Walk over MaterializeTemporaryExpr when reverting an initializer to its
Richard Smith
richard at metafoo.co.uk
Thu May 30 15:46:49 PDT 2013
This fixes a nasty miscompile, please pull to the branch.
On Thu, May 30, 2013 at 3:40 PM, Richard Smith
<richard-llvm at metafoo.co.uk>wrote:
> Author: rsmith
> Date: Thu May 30 17:40:16 2013
> New Revision: 182969
>
> URL: http://llvm.org/viewvc/llvm-project?rev=182969&view=rev
> Log:
> Walk over MaterializeTemporaryExpr when reverting an initializer to its
> syntactic form in template instantiation. Previously, this blocked the
> reversion and we ended up losing inner CXXBindTemporaryExprs (and thus
> forgetting to call destructors!).
>
> Modified:
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-constructors.cpp
>
> Modified: cfe/trunk/lib/Sema/TreeTransform.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=182969&r1=182968&r2=182969&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
> +++ cfe/trunk/lib/Sema/TreeTransform.h Thu May 30 17:40:16 2013
> @@ -2630,6 +2630,9 @@ ExprResult TreeTransform<Derived>::Trans
> if (ExprWithCleanups *ExprTemp = dyn_cast<ExprWithCleanups>(Init))
> Init = ExprTemp->getSubExpr();
>
> + if (MaterializeTemporaryExpr *MTE =
> dyn_cast<MaterializeTemporaryExpr>(Init))
> + Init = MTE->GetTemporaryExpr();
> +
> while (CXXBindTemporaryExpr *Binder =
> dyn_cast<CXXBindTemporaryExpr>(Init))
> Init = Binder->getSubExpr();
>
>
> Modified: cfe/trunk/test/CodeGenCXX/cxx0x-initializer-constructors.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx0x-initializer-constructors.cpp?rev=182969&r1=182968&r2=182969&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/cxx0x-initializer-constructors.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/cxx0x-initializer-constructors.cpp Thu May
> 30 17:40:16 2013
> @@ -35,3 +35,19 @@ void fn4() {
> // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 1, double
> 2.000000e+00, double 3.000000e+00)
> // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 4, double
> 5.000000e+00, double 6.000000e+00)
> }
> +
> +namespace TreeTransformBracedInit {
> + struct S {};
> + struct T { T(const S &); T(const T&); ~T(); };
> + void x(const T &);
> + template<typename> void foo(const S &s) {
> + // Instantiation of this expression used to lose the
> CXXBindTemporaryExpr
> + // node and thus not destroy the temporary.
> + x({s});
> + }
> + template void foo<void>(const S&);
> + // CHECK: define {{.*}} void
> @_ZN23TreeTransformBracedInit3fooIvEEvRKNS_1SE(
> + // CHECK: call void @_ZN23TreeTransformBracedInit1TC1ERKNS_1SE(
> + // CHECK-NEXT: call void @_ZN23TreeTransformBracedInit1xERKNS_1TE(
> + // CHECK-NEXT: call void @_ZN23TreeTransformBracedInit1TD1Ev(
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130530/b6eae402/attachment.html>
More information about the cfe-commits
mailing list