diff options
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index c93d9ba33d..ae05fc5c84 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -659,7 +659,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { DtorTy = getContext().getBaseElementType(Array); if (const RecordType *RT = DtorTy->getAs<RecordType>()) if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) { - if (!ClassDecl->hasTrivialDestructor() && !NRVO) { + if (!ClassDecl->hasTrivialDestructor()) { // Note: We suppress the destructor call when this is an NRVO variable. llvm::Value *Loc = DeclPtr; if (isByRef) @@ -693,7 +693,9 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { EmitCXXAggrDestructorCall(D, Array, BaseAddrPtr); } } else { - { + if (!NRVO) { + // We don't call the destructor along the normal edge if we're + // applying the NRVO. DelayedCleanupBlock Scope(*this); EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false, Loc); @@ -701,6 +703,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { // Make sure to jump to the exit block. EmitBranch(Scope.getCleanupExitBlock()); } + if (Exceptions) { EHCleanupBlock Cleanup(*this); EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false, |