summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-11-06 04:19:02 +0000
committerAnders Carlsson <andersca@mac.com>2009-11-06 04:19:02 +0000
commit421a5c9651232f5553658f57603ce8e61ef28748 (patch)
tree01ef40b1f3f2bc57b753c55c561a93a2bf272993 /clang/lib/CodeGen/CodeGenFunction.cpp
parent529f913f556d5319a0416c3e6ee32977561d28da (diff)
downloadbcm5719-llvm-421a5c9651232f5553658f57603ce8e61ef28748.tar.gz
bcm5719-llvm-421a5c9651232f5553658f57603ce8e61ef28748.zip
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.
llvm-svn: 86230
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 281aa604fe3..9cd44fda954 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -264,6 +264,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD,
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(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<CXXDestructorDecl>(FD)) {
llvm::BasicBlock *DtorEpilogue = createBasicBlock("dtor.epilogue");
PushCleanupBlock(DtorEpilogue);
OpenPOWER on IntegriCloud