25 #include "llvm/IR/CallSite.h" 26 #include "llvm/IR/Intrinsics.h" 27 #include "llvm/IR/IntrinsicInst.h" 28 #include "llvm/Support/SaveAndRestore.h" 30 using namespace clang;
31 using namespace CodeGen;
36 llvm::FunctionType *FTy =
45 llvm::FunctionType *FTy =
54 llvm::FunctionType *FTy =
55 llvm::FunctionType::get(
VoidTy,
false);
62 name =
"_ZSt9terminatev";
66 name =
"__std_terminate";
68 name =
"?terminate@@YAXXZ";
71 name =
"objc_terminate";
79 llvm::FunctionType *FTy =
119 const llvm::Triple &T = Target.
getTriple();
120 if (T.isWindowsMSVCEnvironment())
121 return EHPersonality::MSVC_CxxFrameHandler3;
122 if (L.SjLjExceptions)
124 if (L.DWARFExceptions)
133 const llvm::Triple &T = Target.
getTriple();
134 if (T.isWindowsMSVCEnvironment())
135 return EHPersonality::MSVC_CxxFrameHandler3;
146 return EHPersonality::GNUstep_ObjC;
150 if (L.SjLjExceptions)
156 llvm_unreachable(
"bad runtime kind");
161 const llvm::Triple &T = Target.
getTriple();
162 if (T.isWindowsMSVCEnvironment())
163 return EHPersonality::MSVC_CxxFrameHandler3;
164 if (L.SjLjExceptions)
166 if (L.DWARFExceptions)
171 if (Target.
hasFeature(
"exception-handling") &&
172 (T.getArch() == llvm::Triple::wasm32 ||
173 T.getArch() == llvm::Triple::wasm64))
182 if (Target.
getTriple().isWindowsMSVCEnvironment())
183 return EHPersonality::MSVC_CxxFrameHandler3;
208 llvm_unreachable(
"bad runtime kind");
212 if (T.getArch() == llvm::Triple::x86)
213 return EHPersonality::MSVC_except_handler;
240 return get(CGF.
CGM, dyn_cast_or_null<FunctionDecl>(FD));
247 llvm::AttributeList(),
true);
253 return llvm::ConstantExpr::getBitCast(Fn, CGM.
Int8PtrTy);
258 for (
unsigned I = 0, E = LPI->getNumClauses(); I != E; ++I) {
261 llvm::Value *Val = LPI->getClause(I)->stripPointerCasts();
262 if (LPI->isCatch(I)) {
264 if (llvm::GlobalVariable *GV = dyn_cast<llvm::GlobalVariable>(Val))
267 if (GV->getName().startswith(
"OBJC_EHTYPE"))
271 llvm::Constant *CVal = cast<llvm::Constant>(Val);
272 for (llvm::User::op_iterator
273 II = CVal->op_begin(), IE = CVal->op_end(); II != IE; ++II) {
274 if (llvm::GlobalVariable *GV =
275 cast<llvm::GlobalVariable>((*II)->stripPointerCasts()))
278 if (GV->getName().startswith(
"OBJC_EHTYPE"))
289 for (llvm::User *U : Fn->users()) {
291 if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(U)) {
292 if (CE->getOpcode() != llvm::Instruction::BitCast)
return false;
299 llvm::Function *F = dyn_cast<llvm::Function>(U);
300 if (!F)
return false;
302 for (
auto BB = F->begin(), E = F->end(); BB != E; ++BB) {
303 if (BB->isLandingPad())
316 void CodeGenModule::SimplifyPersonality() {
318 if (!LangOpts.CPlusPlus || !LangOpts.ObjC1 || !LangOpts.Exceptions)
332 "Different EHPersonalities using the same personality function.");
337 if (!Fn || Fn->use_empty())
return;
347 if (Fn->getType() != CXXFn->getType())
return;
349 Fn->replaceAllUsesWith(CXXFn);
350 Fn->eraseFromParent();
357 return llvm::ConstantPointerNull::get(CGF.
Int8PtrTy);
385 Address typedAddr = Builder.CreateBitCast(addr, ty);
398 DeactivateCleanupBlock(cleanup,
399 cast<llvm::Instruction>(typedAddr.
getPointer()));
404 ExceptionSlot = CreateTempAlloca(
Int8PtrTy,
"exn.slot");
410 EHSelectorSlot = CreateTempAlloca(
Int32Ty,
"ehselector.slot");
415 return Builder.CreateLoad(getExceptionSlot(),
"exn");
419 return Builder.CreateLoad(getEHSelectorSlot(),
"sel");
423 bool KeepInsertionPoint) {
425 QualType ThrowType = SubExpr->getType();
429 CGM.getObjCRuntime().EmitThrowStmt(*
this, S,
false);
431 CGM.getCXXABI().emitThrow(*
this, E);
434 CGM.getCXXABI().emitRethrow(*
this,
true);
439 if (KeepInsertionPoint)
440 EmitBlock(createBasicBlock(
"throw.cont"));
444 if (!CGM.getLangOpts().CXXExceptions)
447 const FunctionDecl* FD = dyn_cast_or_null<FunctionDecl>(D);
450 if (
const CapturedDecl* CD = dyn_cast_or_null<CapturedDecl>(D)) {
452 EHStack.pushTerminate();
463 EHStack.pushTerminate();
472 for (
unsigned I = 0; I != NumExceptions; ++I) {
475 llvm::Value *EHType = CGM.GetAddrOfRTTIDescriptor(ExceptType,
486 if (!dispatchBlock)
return;
487 if (dispatchBlock->use_empty()) {
488 delete dispatchBlock;
503 CGF.
Builder.CreateICmpSLT(selector, zero,
"ehspec.fails");
504 CGF.
Builder.CreateCondBr(failsFilter, unexpectedBB,
516 ->setDoesNotReturn();
517 CGF.
Builder.CreateUnreachable();
521 if (!CGM.getLangOpts().CXXExceptions)
524 const FunctionDecl* FD = dyn_cast_or_null<FunctionDecl>(D);
527 if (
const CapturedDecl* CD = dyn_cast_or_null<CapturedDecl>(D)) {
529 EHStack.popTerminate();
539 EHStack.popTerminate();
545 EHFilterScope &filterScope = cast<EHFilterScope>(*EHStack.begin());
559 EHCatchScope *CatchScope = EHStack.pushCatch(NumHandlers);
561 for (
unsigned I = 0; I != NumHandlers; ++I) {
564 llvm::BasicBlock *Handler = createBasicBlock(
"catch");
573 QualType CaughtType = CGM.getContext().getUnqualifiedArrayType(
578 TypeInfo.RTTI = CGM.getObjCRuntime().GetEHType(CaughtType);
580 TypeInfo = CGM.getCXXABI().getAddrOfCXXCatchHandlerType(
585 CatchScope->
setHandler(I, CGM.getCXXABI().getCatchAllTypeInfo(), Handler);
593 return getFuncletEHDispatchBlock(si);
597 if (si == EHStack.stable_end())
598 return getEHResumeBlock(
true);
601 EHScope &scope = *EHStack.find(si);
604 if (!dispatchBlock) {
615 dispatchBlock = createBasicBlock(
"catch.dispatch");
621 dispatchBlock = createBasicBlock(
"ehcleanup");
625 dispatchBlock = createBasicBlock(
"filter.dispatch");
629 dispatchBlock = getTerminateHandler();
633 llvm_unreachable(
"PadEnd unnecessary for Itanium!");
637 return dispatchBlock;
644 if (SI == EHStack.stable_end())
648 EHScope &EHS = *EHStack.find(SI);
652 return DispatchBlock;
655 DispatchBlock = getTerminateFunclet();
657 DispatchBlock = createBasicBlock();
662 DispatchBlock->setName(
"catch.dispatch");
666 DispatchBlock->setName(
"ehcleanup");
670 llvm_unreachable(
"exception specifications not handled yet!");
673 DispatchBlock->setName(
"terminate");
677 llvm_unreachable(
"PadEnd dispatch block missing!");
680 return DispatchBlock;
689 return !cast<EHCleanupScope>(S).isEHCleanup();
697 llvm_unreachable(
"Invalid EHScope Kind!");
701 assert(EHStack.requiresLandingPad());
702 assert(!EHStack.empty());
709 if (!LO.Exceptions) {
710 if (!LO.Borland && !LO.MicrosoftExt)
712 if (!currentFunctionUsesSEHTry())
717 if (LO.CUDA && LO.CUDAIsDevice)
722 llvm::BasicBlock *LP = EHStack.begin()->getCachedLandingPad();
727 if (!CurFn->hasPersonalityFn())
732 LP = getEHDispatchBlock(EHStack.getInnermostEHScope());
735 LP = EmitLandingPad();
743 ir->setCachedLandingPad(LP);
751 assert(EHStack.requiresLandingPad());
753 EHScope &innermostEHScope = *EHStack.find(EHStack.getInnermostEHScope());
754 switch (innermostEHScope.getKind()) {
756 return getTerminateLandingPad();
759 llvm_unreachable(
"PadEnd unnecessary for Itanium!");
764 if (llvm::BasicBlock *lpad = innermostEHScope.getCachedLandingPad())
769 CGBuilderTy::InsertPoint savedIP = Builder.saveAndClearIP();
773 llvm::BasicBlock *lpad = createBasicBlock(
"lpad");
776 llvm::LandingPadInst *LPadInst =
779 llvm::Value *LPadExn = Builder.CreateExtractValue(LPadInst, 0);
780 Builder.CreateStore(LPadExn, getExceptionSlot());
781 llvm::Value *LPadSel = Builder.CreateExtractValue(LPadInst, 1);
782 Builder.CreateStore(LPadSel, getEHSelectorSlot());
790 bool hasCatchAll =
false;
791 bool hasCleanup =
false;
792 bool hasFilter =
false;
794 llvm::SmallPtrSet<llvm::Value*, 4> catchTypes;
798 switch (I->getKind()) {
801 hasCleanup = (hasCleanup || cast<EHCleanupScope>(*I).isEHCleanup());
805 assert(I.next() == EHStack.end() &&
"EH filter is not end of EH stack");
806 assert(!hasCatchAll &&
"EH filter reached after catch-all");
813 for (
unsigned i = 0, e = filter.
getNumFilters(); i != e; ++i)
814 filterTypes.push_back(filter.
getFilter(i));
820 assert(!hasCatchAll);
828 llvm_unreachable(
"PadEnd unnecessary for Itanium!");
832 for (
unsigned hi = 0, he = catchScope.
getNumHandlers(); hi != he; ++hi) {
835 "landingpads do not support catch handler flags");
839 assert(!hasCatchAll);
845 if (catchTypes.insert(handler.
Type.
RTTI).second)
847 LPadInst->addClause(handler.
Type.
RTTI);
853 assert(!(hasCatchAll && hasFilter));
859 }
else if (hasFilter) {
864 llvm::ArrayType *AType =
865 llvm::ArrayType::get(!filterTypes.empty() ?
869 for (
unsigned i = 0, e = filterTypes.size(); i != e; ++i)
870 Filters.push_back(cast<llvm::Constant>(filterTypes[i]));
871 llvm::Constant *FilterArray = llvm::ConstantArray::get(AType, Filters);
872 LPadInst->addClause(FilterArray);
876 LPadInst->setCleanup(
true);
879 }
else if (hasCleanup) {
880 LPadInst->setCleanup(
true);
883 assert((LPadInst->getNumClauses() > 0 || LPadInst->isCleanup()) &&
884 "landingpad instruction has no clauses!");
887 Builder.CreateBr(getEHDispatchBlock(EHStack.getInnermostEHScope()));
890 Builder.restoreIP(savedIP);
897 assert(DispatchBlock);
899 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveIP();
905 llvm::BasicBlock *UnwindBB =
909 llvm::CatchSwitchInst *CatchSwitch =
910 CGF.
Builder.CreateCatchSwitch(ParentPad, UnwindBB, NumHandlers);
913 for (
unsigned I = 0; I < NumHandlers; ++I) {
925 llvm::Constant::getNullValue(CGF.
VoidPtrTy)});
927 CGF.
Builder.CreateCatchPad(CatchSwitch, {TypeInfo.
RTTI});
930 CatchSwitch->addHandler(Handler.
Block);
932 CGF.
Builder.restoreIP(SavedIP);
941 assert(DispatchBlock);
943 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveIP();
949 llvm::BasicBlock *UnwindBB =
953 llvm::CatchSwitchInst *CatchSwitch =
954 CGF.
Builder.CreateCatchSwitch(ParentPad, UnwindBB, NumHandlers);
958 llvm::BasicBlock *WasmCatchStartBlock = CGF.
createBasicBlock(
"catch.start");
959 CatchSwitch->addHandler(WasmCatchStartBlock);
964 for (
unsigned I = 0, E = NumHandlers; I < E; ++I) {
969 CatchTypes.push_back(TypeInfo.
RTTI);
971 auto *CPI = CGF.
Builder.CreateCatchPad(CatchSwitch, CatchTypes);
980 llvm::CallInst *Exn = CGF.
Builder.CreateCall(GetExnFn, CPI);
990 CGF.
Builder.restoreIP(SavedIP);
995 for (
unsigned I = 0, E = NumHandlers;; ++I) {
996 assert(I < E &&
"ran off end of handlers!");
1000 TypeInfo.
RTTI = llvm::Constant::getNullValue(CGF.
VoidPtrTy);
1003 llvm::BasicBlock *NextBlock;
1005 bool EmitNextBlock =
false, NextIsEnd =
false;
1012 EmitNextBlock =
true;
1024 EmitNextBlock =
true;
1028 llvm::CallInst *TypeIndex = CGF.
Builder.CreateCall(TypeIDFn, TypeInfo.
RTTI);
1029 TypeIndex->setDoesNotThrow();
1032 CGF.
Builder.CreateICmpEQ(Selector, TypeIndex,
"matches");
1033 CGF.
Builder.CreateCondBr(MatchesTypeIndex, Handler.
Block, NextBlock);
1041 CGF.
Builder.restoreIP(SavedIP);
1054 assert(dispatchBlock);
1064 CGBuilderTy::InsertPoint savedIP = CGF.
Builder.saveIP();
1076 assert(i < e &&
"ran off end of handlers!");
1081 "landingpads do not support catch handler flags");
1082 assert(typeValue &&
"fell into catch-all case!");
1087 llvm::BasicBlock *nextBlock;
1108 llvm::CallInst *typeIndex =
1109 CGF.
Builder.CreateCall(llvm_eh_typeid_for, typeValue);
1110 typeIndex->setDoesNotThrow();
1113 CGF.
Builder.CreateICmpEQ(selector, typeIndex,
"matches");
1114 CGF.
Builder.CreateCondBr(matchesTypeIndex, handler.
Block, nextBlock);
1118 CGF.
Builder.restoreIP(savedIP);
1127 EHCatchScope &catchScope = cast<EHCatchScope>(*EHStack.begin());
1135 EHCatchScope &CatchScope = cast<EHCatchScope>(*EHStack.begin());
1152 CatchScope.
begin(), CatchScope.
begin() + NumHandlers);
1157 llvm::BasicBlock *ContBB = createBasicBlock(
"try.cont");
1160 if (HaveInsertPoint())
1161 Builder.CreateBr(ContBB);
1165 bool doImplicitRethrow =
false;
1167 doImplicitRethrow = isa<CXXDestructorDecl>(CurCodeDecl) ||
1168 isa<CXXConstructorDecl>(CurCodeDecl);
1175 llvm::BasicBlock *WasmCatchStartBlock =
nullptr;
1178 cast<llvm::CatchSwitchInst>(DispatchBlock->getFirstNonPHI());
1179 WasmCatchStartBlock = CatchSwitch->hasUnwindDest()
1180 ? CatchSwitch->getSuccessor(1)
1181 : CatchSwitch->getSuccessor(0);
1182 auto *CPI = cast<llvm::CatchPadInst>(WasmCatchStartBlock->getFirstNonPHI());
1183 CurrentFuncletPad = CPI;
1193 bool HasCatchAll =
false;
1194 for (
unsigned I = NumHandlers; I != 0; --I) {
1195 HasCatchAll |= Handlers[I - 1].isCatchAll();
1196 llvm::BasicBlock *CatchBlock = Handlers[I-1].Block;
1197 EmitBlockAfterUses(CatchBlock);
1209 CGM.getCXXABI().emitBeginCatch(*
this, C);
1212 incrementProfileCounter(C);
1226 if (doImplicitRethrow && HaveInsertPoint()) {
1227 CGM.getCXXABI().emitRethrow(*
this,
false);
1228 Builder.CreateUnreachable();
1229 Builder.ClearInsertionPoint();
1236 if (HaveInsertPoint())
1237 Builder.CreateBr(ContBB);
1245 assert(WasmCatchStartBlock);
1250 llvm::BasicBlock *RethrowBlock = WasmCatchStartBlock;
1251 while (llvm::TerminatorInst *TI = RethrowBlock->getTerminator()) {
1252 auto *BI = cast<llvm::BranchInst>(TI);
1253 assert(BI->isConditional());
1254 RethrowBlock = BI->getSuccessor(1);
1256 assert(RethrowBlock != WasmCatchStartBlock && RethrowBlock->empty());
1257 Builder.SetInsertPoint(RethrowBlock);
1258 CGM.getCXXABI().emitRethrow(*
this,
true);
1262 incrementProfileCounter(&S);
1270 : ForEHVar(ForEHVar), EndCatchFn(EndCatchFn) {}
1274 llvm::BasicBlock *CleanupContBB =
1279 CGF.
Builder.CreateCondBr(ShouldEndCatch, EndCatchBB, CleanupContBB);
1296 : Body(Body), ForEHVar(ForEHVar), EndCatchFn(EndCatchFn),
1297 RethrowFn(RethrowFn), SavedExnVar(SavedExnVar) {}
1303 ForEHVar, EndCatchFn);
1309 "cleanup.dest.saved");
1322 CGF.
Builder.CreateCondBr(ShouldRethrow, RethrowBB, ContBB);
1331 CGF.
Builder.CreateUnreachable();
1344 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveAndClearIP();
1346 CGF.
Builder.restoreIP(SavedIP);
1361 llvm::Constant *beginCatchFn,
1362 llvm::Constant *endCatchFn,
1363 llvm::Constant *rethrowFn) {
1364 assert((beginCatchFn !=
nullptr) == (endCatchFn !=
nullptr) &&
1365 "begin/end catch functions not paired");
1366 assert(rethrowFn &&
"rethrow function is required");
1368 BeginCatchFn = beginCatchFn;
1376 llvm::FunctionType *rethrowFnTy =
1377 cast<llvm::FunctionType>(
1378 cast<llvm::PointerType>(rethrowFn->getType())->getElementType());
1379 SavedExnVar =
nullptr;
1380 if (rethrowFnTy->getNumParams())
1406 ForEHVar, endCatchFn,
1407 rethrowFn, SavedExnVar);
1423 if (catchBB->use_empty()) {
1426 CGBuilderTy::InsertPoint savedIP = CGF.
Builder.saveAndClearIP();
1449 CGF.
Builder.restoreIP(savedIP);
1457 if (TerminateLandingPad)
1458 return TerminateLandingPad;
1460 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
1463 TerminateLandingPad = createBasicBlock(
"terminate.lpad");
1464 Builder.SetInsertPoint(TerminateLandingPad);
1469 if (!CurFn->hasPersonalityFn())
1472 llvm::LandingPadInst *LPadInst =
1478 Exn = Builder.CreateExtractValue(LPadInst, 0);
1479 llvm::CallInst *terminateCall =
1480 CGM.getCXXABI().emitTerminateForUnexpectedException(*
this, Exn);
1481 terminateCall->setDoesNotReturn();
1482 Builder.CreateUnreachable();
1485 Builder.restoreIP(SavedIP);
1487 return TerminateLandingPad;
1491 if (TerminateHandler)
1492 return TerminateHandler;
1496 TerminateHandler = createBasicBlock(
"terminate.handler");
1497 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
1498 Builder.SetInsertPoint(TerminateHandler);
1502 Exn = getExceptionFromSlot();
1503 llvm::CallInst *terminateCall =
1504 CGM.getCXXABI().emitTerminateForUnexpectedException(*
this, Exn);
1505 terminateCall->setDoesNotReturn();
1506 Builder.CreateUnreachable();
1509 Builder.restoreIP(SavedIP);
1511 return TerminateHandler;
1516 "use getTerminateLandingPad for non-funclet EH");
1518 llvm::BasicBlock *&TerminateFunclet = TerminateFunclets[CurrentFuncletPad];
1519 if (TerminateFunclet)
1520 return TerminateFunclet;
1522 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
1526 TerminateFunclet = createBasicBlock(
"terminate.handler");
1527 Builder.SetInsertPoint(TerminateFunclet);
1535 ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
1536 CurrentFuncletPad = Builder.CreateCleanupPad(ParentPad);
1545 CGM.getIntrinsic(llvm::Intrinsic::wasm_get_exception);
1546 Exn = Builder.CreateCall(GetExnFn, CurrentFuncletPad);
1548 llvm::CallInst *terminateCall =
1549 CGM.getCXXABI().emitTerminateForUnexpectedException(*
this, Exn);
1550 terminateCall->setDoesNotReturn();
1551 Builder.CreateUnreachable();
1554 Builder.restoreIP(SavedIP);
1556 return TerminateFunclet;
1560 if (EHResumeBlock)
return EHResumeBlock;
1562 CGBuilderTy::InsertPoint SavedIP = Builder.saveIP();
1565 EHResumeBlock = createBasicBlock(
"eh.resume");
1566 Builder.SetInsertPoint(EHResumeBlock);
1573 if (RethrowName !=
nullptr && !isCleanup) {
1575 getExceptionFromSlot())->setDoesNotReturn();
1576 Builder.CreateUnreachable();
1577 Builder.restoreIP(SavedIP);
1578 return EHResumeBlock;
1585 llvm::Type *LPadType = llvm::StructType::get(Exn->getType(), Sel->getType());
1586 llvm::Value *LPadVal = llvm::UndefValue::get(LPadType);
1587 LPadVal = Builder.CreateInsertValue(LPadVal, Exn, 0,
"lpad.val");
1588 LPadVal = Builder.CreateInsertValue(LPadVal, Sel, 1,
"lpad.val");
1590 Builder.CreateResume(LPadVal);
1591 Builder.restoreIP(SavedIP);
1592 return EHResumeBlock;
1598 JumpDest TryExit = getJumpDestInCurrentScope(
"__try.__leave");
1600 SEHTryEpilogueStack.push_back(&TryExit);
1602 SEHTryEpilogueStack.pop_back();
1604 if (!TryExit.
getBlock()->use_empty())
1605 EmitBlock(TryExit.
getBlock(),
true);
1614 llvm::Function *OutlinedFinally;
1615 PerformSEHFinally(llvm::Function *OutlinedFinally)
1616 : OutlinedFinally(OutlinedFinally) {}
1629 llvm::ConstantInt::get(CGF.
ConvertType(ArgTys[0]), F.isForEHCleanup());
1651 : ParentCGF(ParentCGF), ParentThis(ParentThis) {}
1654 bool foundCaptures() {
1655 return !Captures.empty() || SEHCodeSlot.
isValid();
1658 void Visit(
const Stmt *S) {
1669 Captures.insert(ParentThis);
1674 if (D && D->isLocalVarDeclOrParm() && D->hasLocalStorage())
1679 Captures.insert(ParentThis);
1682 void VisitCallExpr(
const CallExpr *E) {
1689 case Builtin::BI__exception_code:
1690 case Builtin::BI_exception_code:
1705 llvm::CallInst *RecoverCall =
nullptr;
1707 if (
auto *ParentAlloca = dyn_cast<llvm::AllocaInst>(ParentVar.
getPointer())) {
1710 auto InsertPair = ParentCGF.EscapedLocals.insert(
1711 std::make_pair(ParentAlloca, ParentCGF.EscapedLocals.size()));
1712 int FrameEscapeIdx = InsertPair.first->second;
1714 llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration(
1715 &CGM.getModule(), llvm::Intrinsic::localrecover);
1716 llvm::Constant *ParentI8Fn =
1718 RecoverCall = Builder.CreateCall(
1719 FrameRecoverFn, {ParentI8Fn, ParentFP,
1720 llvm::ConstantInt::get(
Int32Ty, FrameEscapeIdx)});
1726 auto *ParentRecover =
1727 cast<llvm::IntrinsicInst>(ParentVar.
getPointer()->stripPointerCasts());
1728 assert(ParentRecover->getIntrinsicID() == llvm::Intrinsic::localrecover &&
1729 "expected alloca or localrecover in parent LocalDeclMap");
1730 RecoverCall = cast<llvm::CallInst>(ParentRecover->clone());
1731 RecoverCall->setArgOperand(1, ParentFP);
1732 RecoverCall->insertBefore(AllocaInsertPt);
1738 ChildVar->setName(ParentVar.
getName());
1743 const Stmt *OutlinedStmt,
1746 CaptureFinder Finder(ParentCGF, ParentCGF.CXXABIThisDecl);
1747 Finder.Visit(OutlinedStmt);
1751 if (!Finder.foundCaptures() &&
1752 CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
1754 EmitSEHExceptionCodeSave(ParentCGF,
nullptr,
nullptr);
1760 if (IsFilter && CGM.getTarget().getTriple().getArch() == llvm::Triple::x86) {
1764 EntryFP = Builder.CreateCall(
1765 CGM.getIntrinsic(llvm::Intrinsic::frameaddress), {Builder.getInt32(1)});
1769 auto AI = CurFn->arg_begin();
1779 llvm::Function *RecoverFPIntrin =
1780 CGM.getIntrinsic(llvm::Intrinsic::x86_seh_recoverfp);
1781 llvm::Constant *ParentI8Fn =
1783 ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP});
1787 for (
const VarDecl *VD : Finder.Captures) {
1788 if (isa<ImplicitParamDecl>(VD)) {
1789 CGM.ErrorUnsupported(VD,
"'this' captured by SEH");
1790 CXXThisValue = llvm::UndefValue::get(ConvertTypeForMem(VD->
getType()));
1794 CGM.ErrorUnsupported(VD,
"VLA captured by SEH");
1798 "captured non-local variable");
1802 auto I = ParentCGF.LocalDeclMap.find(VD);
1803 if (I == ParentCGF.LocalDeclMap.end())
1806 Address ParentVar = I->second;
1808 VD, recoverAddrOfEscapedLocal(ParentCGF, ParentVar, ParentFP));
1811 if (Finder.SEHCodeSlot.isValid()) {
1812 SEHCodeSlotStack.push_back(
1813 recoverAddrOfEscapedLocal(ParentCGF, Finder.SEHCodeSlot, ParentFP));
1817 EmitSEHExceptionCodeSave(ParentCGF, ParentFP, EntryFP);
1825 const Stmt *OutlinedStmt) {
1831 llvm::raw_svector_ostream OS(Name);
1833 assert(ParentSEHFn &&
"No CurSEHParent!");
1834 MangleContext &Mangler = CGM.getCXXABI().getMangleContext();
1842 if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86 || !IsFilter) {
1848 &
getContext().Idents.get(
"exception_pointers"),
1853 &
getContext().Idents.get(
"abnormal_termination"),
1865 CGM.getTypes().arrangeBuiltinFunctionDeclaration(RetTy, Args);
1867 llvm::FunctionType *FnTy = CGM.getTypes().GetFunctionType(FnInfo);
1871 IsOutlinedSEHHelper =
true;
1873 StartFunction(
GlobalDecl(), RetTy, Fn, FnInfo, Args,
1877 CGM.SetLLVMFunctionAttributes(
nullptr, FnInfo, CurFn);
1878 EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);
1888 startOutlinedSEHHelper(ParentCGF,
true, FilterExpr);
1892 R = Builder.CreateIntCast(R, ConvertType(
getContext().LongTy),
1894 Builder.CreateStore(R, ReturnValue);
1896 FinishFunction(FilterExpr->
getLocEnd());
1905 startOutlinedSEHHelper(ParentCGF,
false, FinallyBlock);
1908 EmitStmt(FinallyBlock);
1910 FinishFunction(FinallyBlock->
getLocEnd());
1920 if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
1922 SEHInfo = &*CurFn->arg_begin();
1923 SEHCodeSlotStack.push_back(
1930 SEHInfo = Builder.CreateConstInBoundsGEP1_32(
Int8Ty, EntryFP, -20);
1931 SEHInfo = Builder.CreateBitCast(SEHInfo,
Int8PtrTy->getPointerTo());
1933 SEHCodeSlotStack.push_back(recoverAddrOfEscapedLocal(
1944 llvm::Type *RecordTy = CGM.Int32Ty->getPointerTo();
1945 llvm::Type *PtrsTy = llvm::StructType::get(RecordTy, CGM.VoidPtrTy);
1946 llvm::Value *Ptrs = Builder.CreateBitCast(SEHInfo, PtrsTy->getPointerTo());
1947 llvm::Value *Rec = Builder.CreateStructGEP(PtrsTy, Ptrs, 0);
1950 assert(!SEHCodeSlotStack.empty() &&
"emitting EH code outside of __except");
1951 Builder.CreateStore(Code, SEHCodeSlotStack.back());
1958 return llvm::UndefValue::get(
Int8PtrTy);
1959 assert(SEHInfo->getType() ==
Int8PtrTy);
1964 assert(!SEHCodeSlotStack.empty() &&
"emitting EH code outside of __except");
1965 return Builder.CreateLoad(SEHCodeSlotStack.back());
1971 auto AI = CurFn->arg_begin();
1972 return Builder.CreateZExt(&*AI,
Int32Ty);
1976 llvm::Function *FinallyFunc) {
1977 EHStack.pushCleanup<PerformSEHFinally>(
Kind, FinallyFunc);
1984 llvm::Function *FinallyFunc =
1996 SEHCodeSlotStack.push_back(
2005 if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86 && C &&
2013 llvm::Function *FilterFunc =
2015 llvm::Constant *OpaqueFunc =
2016 llvm::ConstantExpr::getBitCast(FilterFunc,
Int8PtrTy);
2017 CatchScope->
setHandler(0, OpaqueFunc, createBasicBlock(
"__except.ret"));
2029 assert(Except &&
"__try must have __finally xor __except");
2030 EHCatchScope &CatchScope = cast<EHCatchScope>(*EHStack.begin());
2038 SEHCodeSlotStack.pop_back();
2043 llvm::BasicBlock *ContBB = createBasicBlock(
"__try.cont");
2046 if (HaveInsertPoint())
2047 Builder.CreateBr(ContBB);
2056 EmitBlockAfterUses(CatchPadBB);
2060 llvm::CatchPadInst *CPI =
2061 cast<llvm::CatchPadInst>(CatchPadBB->getFirstNonPHI());
2062 llvm::BasicBlock *ExceptBB = createBasicBlock(
"__except");
2063 Builder.CreateCatchRet(CPI, ExceptBB);
2064 EmitBlock(ExceptBB);
2067 if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
2068 llvm::Function *SEHCodeIntrin =
2069 CGM.getIntrinsic(llvm::Intrinsic::eh_exceptioncode);
2070 llvm::Value *Code = Builder.CreateCall(SEHCodeIntrin, {CPI});
2071 Builder.CreateStore(Code, SEHCodeSlotStack.back());
2078 SEHCodeSlotStack.pop_back();
2080 if (HaveInsertPoint())
2081 Builder.CreateBr(ContBB);
2090 if (HaveInsertPoint())
2095 if (!isSEHTryScope()) {
2096 Builder.CreateUnreachable();
2097 Builder.ClearInsertionPoint();
2101 EmitBranchThroughCleanup(*SEHTryEpilogueStack.back());
virtual void mangleSEHFilterExpression(const NamedDecl *EnclosingDecl, raw_ostream &Out)=0
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Represents a function declaration or definition.
llvm::IntegerType * IntTy
int
EHScopeStack::stable_iterator getEnclosingEHScope() const
CharUnits getIntAlign() const
Other implicit parameter.
CompoundStmt * getBlock() const
Smart pointer class that efficiently represents Objective-C method names.
void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block)
A (possibly-)qualified type.
void EmitSEHLeaveStmt(const SEHLeaveStmt &S)
CodeGenTypes & getTypes()
bool usesFuncletPads() const
Does this personality use landingpads or the family of pad instructions designed to form funclets...
unsigned getNumExceptions() const
const Expr * getSubExpr() const
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
llvm::BasicBlock * getCachedEHDispatchBlock() const
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
static const EHPersonality GNU_C_SJLJ
void EmitCXXTryStmt(const CXXTryStmt &S)
Stmt - This represents one statement.
CXXCatchStmt * getHandler(unsigned i)
static const EHPersonality MSVC_C_specific_handler
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
static const EHPersonality MSVC_CxxFrameHandler3
bool hasEHBranches() const
Decl - This represents one declaration (or definition), e.g.
Stmt * getHandlerBlock() const
void clearHandlerBlocks()
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
Address getEHSelectorSlot()
static const EHPersonality GNU_C
virtual void mangleSEHFinallyBlock(const NamedDecl *EnclosingDecl, raw_ostream &Out)=0
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Represents Objective-C's @throw statement.
static llvm::Constant * getUnexpectedFn(CodeGenModule &CGM)
void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF, llvm::Value *ParentFP, llvm::Value *EntryEBP)
bool usesSEHTry() const
Indicates the function uses __try.
static const EHPersonality & getObjCXXPersonality(const TargetInfo &Target, const LangOptions &L)
Determines the personality function to use when both C++ and Objective-C exceptions are being caught...
static llvm::Constant * getPersonalityFn(CodeGenModule &CGM, const EHPersonality &Personality)
unsigned getNumFilters() const
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
'gcc' is the Objective-C runtime shipped with GCC, implementing a fragile Objective-C ABI ...
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke, SourceLocation Loc)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
Represents a variable declaration or definition.
const T * getAs() const
Member-template getAs<specific type>'.
unsigned getNumHandlers() const
llvm::Value * getPointer() const
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
llvm::BasicBlock * EmitLandingPad()
Emits a landing pad for the current EH stack.
A protected scope for zero-cost EH handling.
Defines the Objective-C statement AST node classes.
A C++ throw-expression (C++ [except.throw]).
static const EHPersonality & getObjCPersonality(const TargetInfo &Target, const LangOptions &L)
A scope which attempts to handle some, possibly all, types of exceptions.
The collection of all-type qualifiers we support.
void add(RValue rvalue, QualType type)
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
void popCatchScope()
popCatchScope - Pops the catch scope at the top of the EHScope stack, emitting any required code (oth...
const TargetInfo & getTarget() const
llvm::BasicBlock * getTerminateHandler()
getTerminateHandler - Return a handler (not a landing pad, just a catch handler) that just calls term...
'macosx-fragile' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the fragil...
const char * CatchallRethrowFn
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
const NamedDecl * CurSEHParent
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getCaughtType() const
SmallVector< Address, 1 > SEHCodeSlotStack
A stack of exception code slots.
static const EHPersonality GNU_CPlusPlus_SJLJ
llvm::CallInst * EmitRuntimeCall(llvm::Value *callee, const Twine &name="")
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
static const EHPersonality & get(CodeGenModule &CGM, const FunctionDecl *FD)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Address getExceptionSlot()
Returns a pointer to the function's exception object and selector slot, which is assigned in every la...
void setFilter(unsigned i, llvm::Value *filterValue)
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
static llvm::Constant * getFreeExceptionFn(CodeGenModule &CGM)
static llvm::Constant * getCatchAllValue(CodeGenFunction &CGF)
Returns the value to inject into a selector to indicate the presence of a catch-all.
void ExitSEHTryStmt(const SEHTryStmt &S)
QualType getExceptionType(unsigned i) const
CharUnits getAlignment() const
Return the alignment of this pointer.
llvm::PointerType * VoidPtrTy
const Handler & getHandler(unsigned I) const
static const EHPersonality GNUstep_ObjC
llvm::Constant * getTerminateFn()
Get the declaration of std::terminate for the platform.
llvm::BasicBlock * getInvokeDestImpl()
llvm::Function * GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF, const SEHFinallyStmt &Finally)
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
void ForceCleanup(std::initializer_list< llvm::Value **> ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
CharUnits getPointerAlign() const
Represents the body of a CapturedStmt, and serves as its DeclContext.
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates an alloca and inserts it into the entry block if ArraySize is nullptr...
CanQualType UnsignedCharTy
llvm::Value * EmitSEHExceptionCode()
Represents the this expression in C++.
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false)
Create a new runtime function with the specified type and name.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
'watchos' is a variant of iOS for Apple's watchOS.
static const EHPersonality & getCPersonality(const TargetInfo &Target, const LangOptions &L)
ASTContext & getContext() const
Represents a prototype with parameter type info, e.g.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
static const EHPersonality MSVC_except_handler
static llvm::Constant * getOpaquePersonalityFn(CodeGenModule &CGM, const EHPersonality &Personality)
Exposes information about the current target.
CatchTypeInfo Type
A type info value, or null (C++ null, not an LLVM null pointer) for a catch-all.
void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt, bool IsFilter)
Scan the outlined statement for captures from the parent function.
Expr - This represents one expression.
void enter(CodeGenFunction &CGF, const Stmt *Finally, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *rethrowFn)
Enters a finally block for an implementation using zero-cost exceptions.
static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn)
Check whether a personality function could reasonably be swapped for a C++ personality function...
'macosx' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the non-fragile AB...
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
llvm::Function * GenerateSEHFilterFunction(CodeGenFunction &ParentCGF, const SEHExceptStmt &Except)
Create a stub filter function that will ultimately hold the code of the filter expression.
llvm::BasicBlock * getBlock() const
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
llvm::Value * EmitSEHExceptionInfo()
VarDecl * getExceptionDecl() const
llvm::PointerType * getType() const
Return the type of the pointer value.
void EmitSEHTryStmt(const SEHTryStmt &S)
llvm::Value * getSelectorFromSlot()
void pushSEHCleanup(CleanupKind kind, llvm::Function *FinallyFunc)
llvm::BasicBlock * Block
The catch handler for this type.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CXXTryStmt - A C++ try block, including all handlers.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
llvm::Value * getExceptionFromSlot()
Returns the contents of the function's exception object and selector slots.
static void emitCatchDispatchBlock(CodeGenFunction &CGF, EHCatchScope &catchScope)
Emit the structure of the dispatch block for the given catch scope.
llvm::LLVMContext & getLLVMContext()
const CGFunctionInfo & arrangeBuiltinFunctionCall(QualType resultType, const CallArgList &args)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
llvm::IntegerType * Int32Ty
static const EHPersonality GNU_ObjCXX
bool hasTerminate() const
Does this runtime provide an objc_terminate function?
clang::ObjCRuntime ObjCRuntime
static const EHPersonality GNU_ObjC_SEH
const TargetInfo & getTarget() const
'gnustep' is the modern non-fragile GNUstep runtime.
const LangOptions & getLangOpts() const
ASTContext & getContext() const
llvm::StoreInst * CreateFlagStore(bool Value, llvm::Value *Addr)
Emit a store to an i1 flag variable.
GlobalDecl - represents a global declaration.
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
llvm::BasicBlock * getEHDispatchBlock(EHScopeStack::stable_iterator scope)
The l-value was considered opaque, so the alignment was determined from a type.
static void emitFilterDispatchBlock(CodeGenFunction &CGF, EHFilterScope &filterScope)
Emit the dispatch block for a filter scope if necessary.
Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF, Address ParentVar, llvm::Value *ParentFP)
Recovers the address of a local in a parent function.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Encodes a location in the source.
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go...
A saved depth on the scope stack.
unsigned getNumHandlers() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
const char * PersonalityFn
'objfw' is the Objective-C runtime included in ObjFW
llvm::BasicBlock * getUnreachableBlock()
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value *> args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
SourceLocation getLocStart() const LLVM_READONLY
static const EHPersonality & getCXXPersonality(const TargetInfo &Target, const LangOptions &L)
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
void EmitStmt(const Stmt *S, ArrayRef< const Attr *> Attrs=None)
EmitStmt - Emit the code for the statement.
bool isObjCObjectPointerType() const
bool isWasmPersonality() const
llvm::BasicBlock * getEHResumeBlock(bool isCleanup)
SourceLocation getLocEnd() const LLVM_READONLY
void setCachedEHDispatchBlock(llvm::BasicBlock *block)
llvm::Instruction * CurrentFuncletPad
llvm::Value * getFilter(unsigned i) const
void exit(CodeGenFunction &CGF)
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
const VersionTuple & getVersion() const
void EmitStartEHSpec(const Decl *D)
EmitStartEHSpec - Emit the start of the exception spec.
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler...
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static const EHPersonality NeXT_ObjC
llvm::BasicBlock * getFuncletEHDispatchBlock(EHScopeStack::stable_iterator scope)
FunctionArgList - Type for representing both the decl and type of parameters to a function...
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
static bool LandingPadHasOnlyCXXUses(llvm::LandingPadInst *LPI)
Check whether a landingpad instruction only uses C++ features.
static const EHPersonality GNU_CPlusPlus_SEH
The basic abstraction for the target Objective-C runtime.
static const EHPersonality GNU_ObjC
static bool isNonEHScope(const EHScope &S)
Check whether this is a non-EH scope, i.e.
void EmitAnyExprToExn(const Expr *E, Address Addr)
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type *> Tys=None)
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
llvm::Module & getModule() const
Address getNormalCleanupDestSlot()
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Represents a __leave statement.
'ios' is the Apple-provided NeXT-derived runtime on iOS or the iOS simulator; it is always non-fragil...
llvm::BasicBlock * getTerminateFunclet()
getTerminateLandingPad - Return a cleanup funclet that just calls terminate.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
static const EHPersonality GNU_CPlusPlus
llvm::PointerType * Int8PtrTy
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
llvm::StringRef getName() const
Return the IR name of the pointer value.
static const EHPersonality GNU_ObjC_SJLJ
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
SEHFinallyStmt * getFinallyHandler() const
static const EHPersonality & getSEHPersonalityMSVC(const llvm::Triple &T)
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Expr * getFilterExpr() const
llvm::BasicBlock * getTerminateLandingPad()
getTerminateLandingPad - Return a landing pad that just calls terminate.
CXXCatchStmt - This represents a C++ catch block.
llvm::Type * ConvertType(QualType T)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
static const EHPersonality GNU_C_SEH
The exceptions personality for a function.
CompoundStmt * getTryBlock()
llvm::Value * EmitSEHAbnormalTermination()
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
llvm::Constant * tryEmitAbstract(const Expr *E, QualType T)
Try to emit the result of the given expression as an abstract constant.
void EnterSEHTryStmt(const SEHTryStmt &S)
void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter, const Stmt *OutlinedStmt)
Arrange a function prototype that can be called by Windows exception handling personalities.
RetTy Visit(PTR(Stmt) S, ParamTys... P)
CGCXXABI & getCXXABI() const
An exceptions scope which filters exceptions thrown through it.
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
void EmitEndEHSpec(const Decl *D)
EmitEndEHSpec - Emit the end of the exception spec.
static llvm::Constant * getCatchallRethrowFn(CodeGenModule &CGM, StringRef Name)
llvm::StoreInst * CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr, CharUnits Align, bool IsVolatile=false)
static const EHPersonality GNU_Wasm_CPlusPlus
Information for lazily generating a cleanup.
This represents a decl that may have a name.
A non-stable pointer into the scope stack.
void EmitBlockAfterUses(llvm::BasicBlock *BB)
EmitBlockAfterUses - Emit the given block somewhere hopefully near its uses, and leave the insertion ...
static void emitCatchPadBlock(CodeGenFunction &CGF, EHCatchScope &CatchScope)
CallArgList - Type for representing both the value and type of arguments in a call.
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block)
CompoundStmt * getTryBlock() const
CompoundStmt * getBlock() const
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
static void emitWasmCatchPadBlock(CodeGenFunction &CGF, EHCatchScope &CatchScope)