llvm::Value *Src = CGF.EmitLValue(E).getAddress();
+ llvm::BasicBlock *TerminateHandler = CGF.getTerminateHandler();
+ llvm::BasicBlock *PrevLandingPad = CGF.getInvokeDest();
+ CGF.setInvokeDest(TerminateHandler);
+
// Stolen from EmitClassAggrMemberwiseCopy
llvm::Value *Callee = CGF.CGM.GetAddrOfCXXConstructor(CopyCtor,
Ctor_Complete);
CopyCtor->getType()->getAs<FunctionType>()->getResultType();
CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
Callee, CallArgs, CopyCtor);
+ CGF.setInvokeDest(PrevLandingPad);
} else
llvm::llvm_unreachable("uncopyable object");
}
llvm::ConstantInt::get(SizeTy, TypeSize),
"exception");
- // FIXME: terminate protect this
CopyObject(*this, E->getSubExpr(), ExceptionPtr);
// Now throw the exception.
}
llvm::BasicBlock *CodeGenFunction::getTerminateHandler() {
+ llvm::BasicBlock *Cont = 0;
+
+ if (HaveInsertPoint()) {
+ Cont = createBasicBlock("cont");
+ EmitBranch(Cont);
+ }
+
llvm::Constant *Personality =
CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::getInt32Ty
(VMContext),
Args.push_back(Exc);
Args.push_back(Personality);
Args.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
- 0));
+ 1));
Builder.CreateCall(llvm_eh_selector, Args.begin(), Args.end());
llvm::CallInst *TerminateCall =
Builder.CreateCall(getTerminateFn(*this));
// Clear the insertion point to indicate we are in unreachable code.
Builder.ClearInsertionPoint();
+ if (Cont)
+ EmitBlock(Cont);
+
return TerminateHandler;
}
// CHECK-NEXT:entry:
// CHECK-NEXT: %exception = call i8* @__cxa_allocate_exception(i64 16)
// CHECK-NEXT: %0 = bitcast i8* %exception to %struct.test2_D*
-// CHECK-NEXT: call void @_ZN7test2_DC1ERKS_(%struct.test2_D* %0, %struct.test2_D* @d2)
-// CHECK-NEXT: call void @__cxa_throw(i8* %exception, i8* bitcast (%0* @_ZTI7test2_D to i8*), i8* null) noreturn
+// CHECK: invoke void @_ZN7test2_DC1ERKS_(%struct.test2_D* %0, %struct.test2_D* @d2)
+// CHECK-NEXT: to label %invoke.cont unwind label %terminate.handler
+// CHECK: call void @__cxa_throw(i8* %exception, i8* bitcast (%0* @_ZTI7test2_D to i8*), i8* null) noreturn
// CHECK-NEXT: unreachable