From 5e1b91875c275f0ec50d3680afbac150d684fdba Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 6 Nov 2009 04:19:02 +0000 Subject: If a member variable of reference type is bound to a temporary in its member initializer it needs to be destroyed at the end of the constructor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86230 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenFunction.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/CodeGen/CodeGenFunction.cpp') diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 281aa604fe..9cd44fda95 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -264,6 +264,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, if (const CXXConstructorDecl *CD = dyn_cast(FD)) { EmitCtorPrologue(CD, GD.getCtorType()); EmitStmt(S); + + // If any of the member initializers are temporaries bound to references + // make sure to emit their destructors. + EmitCleanupBlocks(0); + } else if (const CXXDestructorDecl *DD = dyn_cast(FD)) { llvm::BasicBlock *DtorEpilogue = createBasicBlock("dtor.epilogue"); PushCleanupBlock(DtorEpilogue); -- cgit v1.2.3