summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 5549239a8f7..1a20403e84e 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1807,7 +1807,7 @@ void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) {
HelperCGF.GenerateSEHFilterFunction(*this, *Except);
llvm::Constant *OpaqueFunc =
llvm::ConstantExpr::getBitCast(FilterFunc, Int8PtrTy);
- CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except"));
+ CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except.ret"));
}
void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {
@@ -1848,6 +1848,18 @@ void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {
EmitBlockAfterUses(ExceptBB);
+ if (CGM.getCodeGenOpts().NewMSEH) {
+ // __except blocks don't get outlined into funclets, so immediately do a
+ // catchret.
+ llvm::BasicBlock *CatchPadBB = ExceptBB->getSinglePredecessor();
+ assert(CatchPadBB && "only ExceptBB pred should be catchpad");
+ llvm::CatchPadInst *CPI =
+ cast<llvm::CatchPadInst>(CatchPadBB->getFirstNonPHI());
+ ExceptBB = createBasicBlock("__except");
+ Builder.CreateCatchRet(CPI, ExceptBB);
+ EmitBlock(ExceptBB);
+ }
+
// On Win64, the exception pointer is the exception code. Copy it to the slot.
if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
llvm::Value *Code =
OpenPOWER on IntegriCloud