Go to the documentation of this file.
25 #include "llvm/IR/IntrinsicInst.h"
26 #include "llvm/IR/Intrinsics.h"
27 #include "llvm/IR/IntrinsicsWebAssembly.h"
28 #include "llvm/Support/SaveAndRestore.h"
30 using namespace clang;
31 using namespace CodeGen;
36 llvm::FunctionType *FTy =
43 llvm::FunctionType *FTy =
44 llvm::FunctionType::get(CGM.
VoidTy,
false);
49 llvm::FunctionType *FTy =
50 llvm::FunctionType::get(CGM.
VoidTy,
false);
57 llvm::FunctionType *FTy =
66 llvm::FunctionType *FTy =
67 llvm::FunctionType::get(
VoidTy,
false);
74 name =
"_ZSt9terminatev";
78 name =
"__std_terminate";
80 name =
"?terminate@@YAXXZ";
83 name =
"objc_terminate";
91 llvm::FunctionType *FTy =
133 const llvm::Triple &T =
Target.getTriple();
134 if (T.isWindowsMSVCEnvironment())
147 const llvm::Triple &T =
Target.getTriple();
148 if (T.isWindowsMSVCEnvironment())
170 llvm_unreachable(
"bad runtime kind");
175 const llvm::Triple &T =
Target.getTriple();
176 if (T.isWindowsMSVCEnvironment())
195 if (
Target.getTriple().isWindowsMSVCEnvironment())
221 llvm_unreachable(
"bad runtime kind");
225 if (T.getArch() == llvm::Triple::x86)
253 return get(CGF.
CGM, dyn_cast_or_null<FunctionDecl>(FD));
260 llvm::AttributeList(),
true);
266 llvm::PointerType* Int8PtrTy = llvm::PointerType::get(
270 return llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(Fn.getCallee()),
276 for (
unsigned I = 0, E = LPI->getNumClauses(); I != E; ++I) {
279 llvm::Value *Val = LPI->getClause(I)->stripPointerCasts();
280 if (LPI->isCatch(I)) {
282 if (llvm::GlobalVariable *GV = dyn_cast<llvm::GlobalVariable>(Val))
285 if (GV->getName().startswith(
"OBJC_EHTYPE"))
289 llvm::Constant *CVal = cast<llvm::Constant>(Val);
290 for (llvm::User::op_iterator
291 II = CVal->op_begin(), IE = CVal->op_end(); II != IE; ++II) {
292 if (llvm::GlobalVariable *GV =
293 cast<llvm::GlobalVariable>((*II)->stripPointerCasts()))
296 if (GV->getName().startswith(
"OBJC_EHTYPE"))
307 for (llvm::User *
U : Fn->users()) {
309 if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(
U)) {
310 if (CE->getOpcode() != llvm::Instruction::BitCast)
return false;
317 llvm::Function *F = dyn_cast<llvm::Function>(
U);
318 if (!F)
return false;
320 for (
auto BB = F->begin(), E = F->end(); BB != E; ++BB) {
321 if (BB->isLandingPad())
334 void CodeGenModule::SimplifyPersonality() {
336 if (!LangOpts.CPlusPlus || !LangOpts.ObjC || !LangOpts.Exceptions)
349 assert(std::strcmp(
ObjCXX.PersonalityFn,
CXX.PersonalityFn) != 0 &&
350 "Different EHPersonalities using the same personality function.");
355 if (!Fn || Fn->use_empty())
return;
365 if (Fn->getType() != CXXFn.getCallee()->getType())
368 Fn->replaceAllUsesWith(CXXFn.getCallee());
369 Fn->eraseFromParent();
376 return llvm::ConstantPointerNull::get(CGF.
Int8PtrTy);
384 FreeException(llvm::Value *exn) : exn(exn) {}
418 cast<llvm::Instruction>(typedAddr.
getPointer()));
442 bool KeepInsertionPoint) {
444 QualType ThrowType = SubExpr->getType();
458 if (KeepInsertionPoint)
466 const FunctionDecl* FD = dyn_cast_or_null<FunctionDecl>(D);
469 if (
const CapturedDecl* CD = dyn_cast_or_null<CapturedDecl>(D)) {
497 diag::warn_wasm_dynamic_exception_spec_ignored)
511 diag::warn_wasm_dynamic_exception_spec_ignored)
517 for (
unsigned I = 0; I != NumExceptions; ++I) {
522 Filter->setFilter(I, EHType);
535 if (!dispatchBlock)
return;
536 if (dispatchBlock->use_empty()) {
537 delete dispatchBlock;
550 llvm::Value *zero = CGF.
Builder.getInt32(0);
551 llvm::Value *failsFilter =
552 CGF.
Builder.CreateICmpSLT(selector, zero,
"ehspec.fails");
553 CGF.
Builder.CreateCondBr(failsFilter, unexpectedBB,
565 ->setDoesNotReturn();
566 CGF.
Builder.CreateUnreachable();
573 const FunctionDecl* FD = dyn_cast_or_null<FunctionDecl>(D);
576 if (
const CapturedDecl* CD = dyn_cast_or_null<CapturedDecl>(D)) {
618 unsigned NumHandlers = S.getNumHandlers();
621 for (
unsigned I = 0; I != NumHandlers; ++I) {
625 if (C->getExceptionDecl()) {
634 C->getCaughtType().getNonReferenceType(), CaughtTypeQuals);
641 CaughtType, C->getCaughtType());
668 if (!dispatchBlock) {
698 return dispatchBlock;
713 return DispatchBlock;
723 DispatchBlock->setName(
"catch.dispatch");
727 DispatchBlock->setName(
"ehcleanup");
731 llvm_unreachable(
"exception specifications not handled yet!");
734 DispatchBlock->setName(
"terminate");
738 return DispatchBlock;
745 switch (S.getKind()) {
747 return !cast<EHCleanupScope>(S).isEHCleanup();
754 llvm_unreachable(
"Invalid EHScope Kind!");
766 if (!LO.Exceptions || LO.IgnoreExceptions) {
767 if (!LO.Borland && !LO.MicrosoftExt)
774 if (LO.CUDA && LO.CUDAIsDevice)
784 if (!
CurFn->hasPersonalityFn())
800 ir->setCachedLandingPad(LP);
810 "LandingPad should not be emitted when -fignore-exceptions are in "
813 switch (innermostEHScope.
getKind()) {
825 CGBuilderTy::InsertPoint savedIP =
Builder.saveAndClearIP();
832 llvm::LandingPadInst *LPadInst =
835 llvm::Value *LPadExn =
Builder.CreateExtractValue(LPadInst, 0);
837 llvm::Value *LPadSel =
Builder.CreateExtractValue(LPadInst, 1);
846 bool hasCatchAll =
false;
847 bool hasCleanup =
false;
848 bool hasFilter =
false;
854 switch (I->getKind()) {
857 hasCleanup = (hasCleanup || cast<EHCleanupScope>(*I).isEHCleanup());
861 assert(I.next() ==
EHStack.
end() &&
"EH filter is not end of EH stack");
862 assert(!hasCatchAll &&
"EH filter reached after catch-all");
869 for (
unsigned i = 0, e = filter.
getNumFilters(); i != e; ++i)
870 filterTypes.push_back(filter.
getFilter(i));
876 assert(!hasCatchAll);
885 for (
unsigned hi = 0, he = catchScope.
getNumHandlers(); hi != he; ++hi) {
888 "landingpads do not support catch handler flags");
892 assert(!hasCatchAll);
898 if (catchTypes.insert(handler.
Type.
RTTI).second)
900 LPadInst->addClause(handler.
Type.
RTTI);
906 assert(!(hasCatchAll && hasFilter));
912 }
else if (hasFilter) {
917 llvm::ArrayType *AType =
918 llvm::ArrayType::get(!filterTypes.empty() ?
922 for (
unsigned i = 0, e = filterTypes.size(); i != e; ++i)
923 Filters.push_back(cast<llvm::Constant>(filterTypes[i]));
924 llvm::Constant *FilterArray = llvm::ConstantArray::get(AType, Filters);
925 LPadInst->addClause(FilterArray);
929 LPadInst->setCleanup(
true);
932 }
else if (hasCleanup) {
933 LPadInst->setCleanup(
true);
936 assert((LPadInst->getNumClauses() > 0 || LPadInst->isCleanup()) &&
937 "landingpad instruction has no clauses!");
950 assert(DispatchBlock);
952 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveIP();
958 llvm::BasicBlock *UnwindBB =
962 llvm::CatchSwitchInst *CatchSwitch =
963 CGF.
Builder.CreateCatchSwitch(ParentPad, UnwindBB, NumHandlers);
966 for (
unsigned I = 0; I < NumHandlers; ++I) {
978 llvm::Constant::getNullValue(CGF.
VoidPtrTy)});
983 CatchSwitch->addHandler(Handler.
Block);
985 CGF.
Builder.restoreIP(SavedIP);
994 assert(DispatchBlock);
996 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveIP();
1002 llvm::BasicBlock *UnwindBB =
1006 llvm::CatchSwitchInst *CatchSwitch =
1007 CGF.
Builder.CreateCatchSwitch(ParentPad, UnwindBB, NumHandlers);
1011 llvm::BasicBlock *WasmCatchStartBlock = CGF.
createBasicBlock(
"catch.start");
1012 CatchSwitch->addHandler(WasmCatchStartBlock);
1017 for (
unsigned I = 0, E = NumHandlers; I < E; ++I) {
1022 CatchTypes.push_back(
TypeInfo.RTTI);
1024 auto *CPI = CGF.
Builder.CreateCatchPad(CatchSwitch, CatchTypes);
1029 llvm::Function *GetExnFn =
1031 llvm::Function *GetSelectorFn =
1033 llvm::CallInst *Exn = CGF.
Builder.CreateCall(GetExnFn, CPI);
1035 llvm::CallInst *
Selector = CGF.
Builder.CreateCall(GetSelectorFn, CPI);
1037 llvm::Function *TypeIDFn = CGF.
CGM.
getIntrinsic(llvm::Intrinsic::eh_typeid_for);
1043 CGF.
Builder.restoreIP(SavedIP);
1048 for (
unsigned I = 0, E = NumHandlers;; ++I) {
1049 assert(I < E &&
"ran off end of handlers!");
1056 llvm::BasicBlock *NextBlock;
1058 bool EmitNextBlock =
false, NextIsEnd =
false;
1065 EmitNextBlock =
true;
1077 EmitNextBlock =
true;
1081 llvm::CallInst *TypeIndex = CGF.
Builder.CreateCall(TypeIDFn,
TypeInfo.RTTI);
1082 TypeIndex->setDoesNotThrow();
1084 llvm::Value *MatchesTypeIndex =
1086 CGF.
Builder.CreateCondBr(MatchesTypeIndex, Handler.
Block, NextBlock);
1094 CGF.
Builder.restoreIP(SavedIP);
1107 assert(dispatchBlock);
1117 CGBuilderTy::InsertPoint savedIP = CGF.
Builder.saveIP();
1121 llvm::Function *llvm_eh_typeid_for =
1129 assert(i < e &&
"ran off end of handlers!");
1132 llvm::Value *typeValue = handler.
Type.
RTTI;
1134 "landingpads do not support catch handler flags");
1135 assert(typeValue &&
"fell into catch-all case!");
1140 llvm::BasicBlock *nextBlock;
1161 llvm::CallInst *typeIndex =
1162 CGF.
Builder.CreateCall(llvm_eh_typeid_for, typeValue);
1163 typeIndex->setDoesNotThrow();
1165 llvm::Value *matchesTypeIndex =
1166 CGF.
Builder.CreateICmpEQ(selector, typeIndex,
"matches");
1167 CGF.
Builder.CreateCondBr(matchesTypeIndex, handler.
Block, nextBlock);
1171 CGF.
Builder.restoreIP(savedIP);
1187 unsigned NumHandlers = S.getNumHandlers();
1205 CatchScope.
begin(), CatchScope.
begin() + NumHandlers);
1218 bool doImplicitRethrow =
false;
1220 doImplicitRethrow = isa<CXXDestructorDecl>(
CurCodeDecl) ||
1228 llvm::BasicBlock *WasmCatchStartBlock =
nullptr;
1231 cast<llvm::CatchSwitchInst>(DispatchBlock->getFirstNonPHI());
1232 WasmCatchStartBlock = CatchSwitch->hasUnwindDest()
1233 ? CatchSwitch->getSuccessor(1)
1234 : CatchSwitch->getSuccessor(0);
1235 auto *CPI = cast<llvm::CatchPadInst>(WasmCatchStartBlock->getFirstNonPHI());
1246 bool HasCatchAll =
false;
1247 for (
unsigned I = NumHandlers; I != 0; --I) {
1248 HasCatchAll |= Handlers[I - 1].isCatchAll();
1249 llvm::BasicBlock *CatchBlock = Handlers[I-1].Block;
1282 Builder.ClearInsertionPoint();
1298 assert(WasmCatchStartBlock);
1303 llvm::BasicBlock *RethrowBlock = WasmCatchStartBlock;
1304 while (llvm::Instruction *TI = RethrowBlock->getTerminator()) {
1305 auto *BI = cast<llvm::BranchInst>(TI);
1306 assert(BI->isConditional());
1307 RethrowBlock = BI->getSuccessor(1);
1309 assert(RethrowBlock != WasmCatchStartBlock && RethrowBlock->empty());
1310 Builder.SetInsertPoint(RethrowBlock);
1311 llvm::Function *RethrowInCatchFn =
1322 llvm::Value *ForEHVar;
1323 llvm::FunctionCallee EndCatchFn;
1324 CallEndCatchForFinally(llvm::Value *ForEHVar,
1325 llvm::FunctionCallee EndCatchFn)
1326 : ForEHVar(ForEHVar), EndCatchFn(EndCatchFn) {}
1330 llvm::BasicBlock *CleanupContBB =
1333 llvm::Value *ShouldEndCatch =
1335 CGF.
Builder.CreateCondBr(ShouldEndCatch, EndCatchBB, CleanupContBB);
1344 llvm::Value *ForEHVar;
1345 llvm::FunctionCallee EndCatchFn;
1346 llvm::FunctionCallee RethrowFn;
1347 llvm::Value *SavedExnVar;
1349 PerformFinally(
const Stmt *Body, llvm::Value *ForEHVar,
1350 llvm::FunctionCallee EndCatchFn,
1351 llvm::FunctionCallee RethrowFn, llvm::Value *SavedExnVar)
1352 : Body(Body), ForEHVar(ForEHVar), EndCatchFn(EndCatchFn),
1353 RethrowFn(RethrowFn), SavedExnVar(SavedExnVar) {}
1359 ForEHVar, EndCatchFn);
1363 llvm::Value *SavedCleanupDest =
1365 "cleanup.dest.saved");
1376 llvm::Value *ShouldRethrow =
1378 CGF.
Builder.CreateCondBr(ShouldRethrow, RethrowBB, ContBB);
1388 CGF.
Builder.CreateUnreachable();
1401 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveAndClearIP();
1403 CGF.
Builder.restoreIP(SavedIP);
1417 llvm::FunctionCallee beginCatchFn,
1418 llvm::FunctionCallee endCatchFn,
1419 llvm::FunctionCallee rethrowFn) {
1420 assert((!!beginCatchFn) == (!!endCatchFn) &&
1421 "begin/end catch functions not paired");
1422 assert(rethrowFn &&
"rethrow function is required");
1424 BeginCatchFn = beginCatchFn;
1432 llvm::FunctionType *rethrowFnTy = rethrowFn.getFunctionType();
1433 SavedExnVar =
nullptr;
1434 if (rethrowFnTy->getNumParams())
1460 ForEHVar, endCatchFn,
1461 rethrowFn, SavedExnVar);
1477 if (catchBB->use_empty()) {
1480 CGBuilderTy::InsertPoint savedIP = CGF.
Builder.saveAndClearIP();
1483 llvm::Value *exn =
nullptr;
1503 CGF.
Builder.restoreIP(savedIP);
1511 if (TerminateLandingPad)
1512 return TerminateLandingPad;
1514 CGBuilderTy::InsertPoint SavedIP =
Builder.saveAndClearIP();
1518 Builder.SetInsertPoint(TerminateLandingPad);
1523 if (!
CurFn->hasPersonalityFn())
1526 llvm::LandingPadInst *LPadInst =
1530 llvm::Value *Exn =
nullptr;
1532 Exn =
Builder.CreateExtractValue(LPadInst, 0);
1533 llvm::CallInst *terminateCall =
1535 terminateCall->setDoesNotReturn();
1541 return TerminateLandingPad;
1545 if (TerminateHandler)
1546 return TerminateHandler;
1551 CGBuilderTy::InsertPoint SavedIP =
Builder.saveAndClearIP();
1552 Builder.SetInsertPoint(TerminateHandler);
1554 llvm::Value *Exn =
nullptr;
1557 llvm::CallInst *terminateCall =
1559 terminateCall->setDoesNotReturn();
1565 return TerminateHandler;
1570 "use getTerminateLandingPad for non-funclet EH");
1573 if (TerminateFunclet)
1574 return TerminateFunclet;
1576 CGBuilderTy::InsertPoint SavedIP =
Builder.saveAndClearIP();
1581 Builder.SetInsertPoint(TerminateFunclet);
1593 llvm::CallInst *terminateCall =
1595 terminateCall->setDoesNotReturn();
1601 return TerminateFunclet;
1607 CGBuilderTy::InsertPoint SavedIP =
Builder.saveIP();
1618 if (RethrowName !=
nullptr && !isCleanup) {
1630 llvm::Type *LPadType = llvm::StructType::get(Exn->getType(), Sel->getType());
1631 llvm::Value *LPadVal = llvm::UndefValue::get(LPadType);
1632 LPadVal =
Builder.CreateInsertValue(LPadVal, Exn, 0,
"lpad.val");
1633 LPadVal =
Builder.CreateInsertValue(LPadVal, Sel, 1,
"lpad.val");
1635 Builder.CreateResume(LPadVal);
1647 llvm::BasicBlock *TryBB =
nullptr;
1652 TryBB =
Builder.GetInsertBlock();
1665 if (!TryExit.
getBlock()->use_empty())
1678 !
V.insert(BB).second ||
1679 !BB->getParent() || BB->empty())
1682 if (!BB->isEHPad()) {
1683 for (llvm::BasicBlock::iterator J = BB->begin(), JE = BB->end(); J != JE;
1685 if (
auto LI = dyn_cast<llvm::LoadInst>(J)) {
1686 LI->setVolatile(
true);
1687 }
else if (
auto SI = dyn_cast<llvm::StoreInst>(J)) {
1688 SI->setVolatile(
true);
1689 }
else if (
auto* MCI = dyn_cast<llvm::MemIntrinsic>(J)) {
1690 MCI->setVolatile(llvm::ConstantInt::get(
Builder.getInt1Ty(), 1));
1694 const llvm::Instruction *TI = BB->getTerminator();
1696 unsigned N = TI->getNumSuccessors();
1697 for (
unsigned I = 0; I < N; I++)
1704 llvm::Function *OutlinedFinally;
1705 PerformSEHFinally(llvm::Function *OutlinedFinally)
1706 : OutlinedFinally(OutlinedFinally) {}
1716 llvm::Value *FP =
nullptr;
1719 FP = &CGF.
CurFn->arg_begin()[1];
1721 llvm::Function *LocalAddrFn =
1723 FP = CGF.
Builder.CreateCall(LocalAddrFn);
1726 llvm::Value *IsForEH =
1727 llvm::ConstantInt::get(CGF.
ConvertType(ArgTys[0]), F.isForEHCleanup());
1734 if (!F.isForEHCleanup() && F.hasExitSwitch()) {
1765 bool foundCaptures() {
1766 return !Captures.empty() || SEHCodeSlot.
isValid();
1769 void Visit(
const Stmt *S) {
1772 for (
const Stmt *Child : S->children())
1780 Captures.insert(ParentThis);
1782 const auto *D = dyn_cast<VarDecl>(E->
getDecl());
1783 if (D && D->isLocalVarDeclOrParm() && D->hasLocalStorage())
1788 Captures.insert(ParentThis);
1791 void VisitCallExpr(
const CallExpr *E) {
1798 case Builtin::BI__exception_code:
1799 case Builtin::BI_exception_code:
1813 llvm::Value *ParentFP) {
1814 llvm::CallInst *RecoverCall =
nullptr;
1816 if (
auto *ParentAlloca = dyn_cast<llvm::AllocaInst>(ParentVar.
getPointer())) {
1819 auto InsertPair =
ParentCGF.EscapedLocals.insert(
1820 std::make_pair(ParentAlloca,
ParentCGF.EscapedLocals.size()));
1821 int FrameEscapeIdx = InsertPair.first->second;
1823 llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration(
1825 llvm::Constant *ParentI8Fn =
1827 RecoverCall =
Builder.CreateCall(
1828 FrameRecoverFn, {ParentI8Fn, ParentFP,
1829 llvm::ConstantInt::get(
Int32Ty, FrameEscapeIdx)});
1835 auto *ParentRecover =
1836 cast<llvm::IntrinsicInst>(ParentVar.
getPointer()->stripPointerCasts());
1837 assert(ParentRecover->getIntrinsicID() == llvm::Intrinsic::localrecover &&
1838 "expected alloca or localrecover in parent LocalDeclMap");
1839 RecoverCall = cast<llvm::CallInst>(ParentRecover->clone());
1840 RecoverCall->setArgOperand(1, ParentFP);
1845 llvm::Value *ChildVar =
1847 ChildVar->setName(ParentVar.
getName());
1852 const Stmt *OutlinedStmt,
1856 Finder.Visit(OutlinedStmt);
1860 if (!Finder.foundCaptures() &&
1867 llvm::Value *EntryFP =
nullptr;
1875 {Builder.getInt32(1)});
1879 auto AI =
CurFn->arg_begin();
1884 llvm::Value *ParentFP = EntryFP;
1889 llvm::Function *RecoverFPIntrin =
1891 llvm::Constant *ParentI8Fn =
1893 ParentFP =
Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP});
1905 llvm::AllocaInst *FramePtrAddrAlloca =
nullptr;
1906 for (
auto &I :
ParentCGF.LocalDeclMap) {
1907 const VarDecl *D = cast<VarDecl>(I.first);
1908 if (isa<ImplicitParamDecl>(D) &&
1910 assert(D->
getName().startswith(
"frame_pointer"));
1911 FramePtrAddrAlloca = cast<llvm::AllocaInst>(I.second.getPointer());
1915 assert(FramePtrAddrAlloca);
1916 auto InsertPair =
ParentCGF.EscapedLocals.insert(
1917 std::make_pair(FramePtrAddrAlloca,
ParentCGF.EscapedLocals.size()));
1918 int FrameEscapeIdx = InsertPair.first->second;
1926 llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration(
1928 llvm::Constant *ParentI8Fn =
1930 ParentFP =
Builder.CreateCall(
1931 FrameRecoverFn, {ParentI8Fn, ParentFP,
1932 llvm::ConstantInt::get(
Int32Ty, FrameEscapeIdx)});
1940 for (
const VarDecl *VD : Finder.Captures) {
1946 "captured non-local variable");
1956 auto I =
ParentCGF.LocalDeclMap.find(VD);
1960 Address ParentVar = I->second;
1963 setAddrOfLocalVar(VD, Recovered);
1965 if (isa<ImplicitParamDecl>(VD)) {
1966 CXXABIThisAlignment =
ParentCGF.CXXABIThisAlignment;
1967 CXXThisAlignment =
ParentCGF.CXXThisAlignment;
1982 CXXThisValue = CXXABIThisValue;
1987 if (Finder.SEHCodeSlot.isValid()) {
2001 const Stmt *OutlinedStmt) {
2007 llvm::raw_svector_ostream OS(Name);
2009 assert(ParentSEHFn &&
"No CurSEHParent!");
2024 &
getContext().Idents.get(
"exception_pointers"),
2029 &
getContext().Idents.get(
"abnormal_termination"),
2044 llvm::Function *Fn = llvm::Function::Create(
2092 llvm::Value *ParentFP,
2093 llvm::Value *EntryFP) {
2120 llvm::Type *RecordTy =
CGM.
Int32Ty->getPointerTo();
2121 llvm::Type *PtrsTy = llvm::StructType::get(RecordTy,
CGM.
VoidPtrTy);
2122 llvm::Value *Ptrs =
Builder.CreateBitCast(
SEHInfo, PtrsTy->getPointerTo());
2126 assert(!
SEHCodeSlotStack.empty() &&
"emitting EH code outside of __except");
2134 return llvm::UndefValue::get(
Int8PtrTy);
2140 assert(!
SEHCodeSlotStack.empty() &&
"emitting EH code outside of __except");
2147 auto AI =
CurFn->arg_begin();
2152 llvm::Function *FinallyFunc) {
2153 EHStack.pushCleanup<PerformSEHFinally>(
Kind, FinallyFunc);
2161 llvm::Function *FinallyFunc =
2190 llvm::Function *FilterFunc =
2192 llvm::Constant *OpaqueFunc =
2193 llvm::ConstantExpr::getBitCast(FilterFunc,
Int8PtrTy);
2199 if (S.getFinallyHandler()) {
2212 assert(Except &&
"__try must have __finally xor __except");
2243 llvm::CatchPadInst *CPI =
2244 cast<llvm::CatchPadInst>(CatchPadBB->getFirstNonPHI());
2246 Builder.CreateCatchRet(CPI, ExceptBB);
2251 llvm::Function *SEHCodeIntrin =
2253 llvm::Value *Code =
Builder.CreateCall(SEHCodeIntrin, {CPI});
2280 Builder.ClearInsertionPoint();
Address getEHSelectorSlot()
bool isWasmPersonality() const
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static void emitCatchPadBlock(CodeGenFunction &CGF, EHCatchScope &CatchScope)
llvm::Type * ConvertTypeForMem(QualType T)
static const EHPersonality & getSEHPersonalityMSVC(const llvm::Triple &T)
static const EHPersonality GNU_C_SJLJ
void EmitBlockAfterUses(llvm::BasicBlock *BB)
EmitBlockAfterUses - Emit the given block somewhere hopefully near its uses, and leave the insertion ...
bool hasSEHExceptions() const
bool isSEHTryScope() const
Returns true inside SEH __try blocks.
void EmitCXXTryStmt(const CXXTryStmt &S)
llvm::PointerType * Int8PtrTy
static const EHPersonality & getObjCPersonality(const TargetInfo &Target, const LangOptions &L)
static const EHPersonality NeXT_ObjC
void EmitEndEHSpec(const Decl *D)
EmitEndEHSpec - Emit the end of the exception spec.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
llvm::IntegerType * IntTy
int
llvm::FunctionCallee CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false, bool AssumeConvergent=false)
Create or return a runtime function declaration with the specified type and name.
static const EHPersonality GNU_C
llvm::BasicBlock * getTerminateLandingPad()
getTerminateLandingPad - Return a landing pad that just calls terminate.
static const EHPersonality GNUstep_ObjC
llvm::Value * EmitSEHAbnormalTermination()
@ GCC
'gcc' is the Objective-C runtime shipped with GCC, implementing a fragile Objective-C ABI
static const EHPersonality GNU_CPlusPlus_SEH
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **callOrInvoke, bool IsMustTail, SourceLocation Loc)
EmitCall - Generate a call of the given function, expecting the given result type,...
bool currentFunctionUsesSEHTry() const
virtual CatchTypeInfo getAddrOfCXXCatchHandlerType(QualType Ty, QualType CatchHandlerType)=0
llvm::DenseMap< const VarDecl *, FieldDecl * > LambdaCaptureFields
class EHFilterScope * pushFilter(unsigned NumFilters)
Push an exceptions filter on the stack.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
Encodes a location in the source.
void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
MangleContext & getMangleContext()
Gets the mangle context.
Address getAddress(CodeGenFunction &CGF) const
This represents a decl that may have a name.
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block)
llvm::BasicBlock * getCachedLandingPad() const
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void enter(CodeGenFunction &CGF, const Stmt *Finally, llvm::FunctionCallee beginCatchFn, llvm::FunctionCallee endCatchFn, llvm::FunctionCallee rethrowFn)
Enters a finally block for an implementation using zero-cost exceptions.
SourceRange getExceptionSpecSourceRange() const
Attempt to compute an informative source range covering the function exception specification,...
CharUnits getPointerAlign() const
A (possibly-)qualified type.
A protected scope for zero-cost EH handling.
const Handler & getHandler(unsigned I) const
ASTContext & getContext() const
llvm::BasicBlock * getTerminateHandler()
getTerminateHandler - Return a handler (not a landing pad, just a catch handler) that just calls term...
@ EST_Dynamic
throw(T1, T2)
The collection of all-type qualifiers we support.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
LValue EmitLValueForLambdaField(const FieldDecl *Field)
Given that we are currently emitting a lambda, emit an l-value for one of its members.
Exposes information about the current target.
llvm::Value * SEHInfo
Value returned by __exception_info intrinsic.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
static const EHPersonality GNU_Wasm_CPlusPlus
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
static const EHPersonality GNU_ObjC_SEH
llvm::SmallVector< const JumpDest *, 2 > SEHTryEpilogueStack
bool hasEHBranches() const
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
const char * CatchallRethrowFn
void EmitNoreturnRuntimeCallOrInvoke(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
void popCatchScope()
popCatchScope - Pops the catch scope at the top of the EHScope stack, emitting any required code (oth...
llvm::Value * EmitSEHExceptionCode()
const LangOptions & getLangOpts() const
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
@ EHCleanup
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
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...
bool hasTerminate() const
Does this runtime provide an objc_terminate function?
virtual void emitRethrow(CodeGenFunction &CGF, bool isNoReturn)=0
void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF, llvm::Value *ParentFP, llvm::Value *EntryEBP)
bool hasDWARFExceptions() const
Represents the body of a CapturedStmt, and serves as its DeclContext.
const char * PersonalityFn
CharUnits getIntAlign() const
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name="")
void EmitStmt(const Stmt *S, ArrayRef< const Attr * > Attrs=None)
EmitStmt - Emit the code for the statement.
CompoundStmt * getBlock() const
llvm::BasicBlock * getBlock() const
static const EHPersonality & get(CodeGenModule &CGM, const FunctionDecl *FD)
static const EHPersonality GNU_C_SEH
void add(RValue rvalue, QualType type)
llvm::BasicBlock * Block
The catch handler for this type.
llvm::PointerType * VoidPtrTy
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.
const VersionTuple & getVersion() const
A C++ throw-expression (C++ [except.throw]).
static llvm::FunctionCallee getUnexpectedFn(CodeGenModule &CGM)
GlobalDecl - represents a global declaration.
llvm::PointerType * AllocaInt8PtrTy
virtual CatchTypeInfo getCatchAllTypeInfo()
@ FragileMacOSX
'macosx-fragile' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the fragil...
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
static llvm::FunctionCallee getPersonalityFn(CodeGenModule &CGM, const EHPersonality &Personality)
bool usesFuncletPads() const
Does this personality use landingpads or the family of pad instructions designed to form funclets?
virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, bool ClearInsertionPoint=true)=0
unsigned getNumHandlers() const
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
A scope which attempts to handle some, possibly all, types of exceptions.
llvm::BasicBlock * getInvokeDestImpl()
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
llvm::BasicBlock * EHResumeBlock
EHResumeBlock - Unified block containing a call to llvm.eh.resume.
@ MacOSX
'macosx' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the non-fragile AB...
Information for lazily generating a cleanup.
llvm::Value * EmitSEHExceptionInfo()
SmallVector< Address, 1 > SEHCodeSlotStack
A stack of exception code slots.
clang::ObjCRuntime ObjCRuntime
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
void pushSEHCleanup(CleanupKind kind, llvm::Function *FinallyFunc)
llvm::StoreInst * CreateAlignedStore(llvm::Value *Val, llvm::Value *Addr, CharUnits Align, bool IsVolatile=false)
void EmitCapturedLocals(CodeGenFunction &ParentCGF, const Stmt *OutlinedStmt, bool IsFilter)
Scan the outlined statement for captures from the parent function.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
llvm::StringRef getName() const
Return the IR name of the pointer value.
Represents Objective-C's @throw statement.
bool hasWasmExceptions() const
CatchTypeInfo Type
A type info value, or null (C++ null, not an LLVM null pointer) for a catch-all.
const NamedDecl * CurSEHParent
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
llvm::PointerType * getType() const
Return the type of the pointer value.
static const EHPersonality GNU_ObjCXX
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
virtual void emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E)=0
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go.
const T * getAs() const
Member-template getAs<specific type>'.
const TargetInfo & getTarget() const
Address getExceptionSlot()
Returns a pointer to the function's exception object and selector slot, which is assigned in every la...
void setCachedEHDispatchBlock(llvm::BasicBlock *block)
void VolatilizeTryBlocks(llvm::BasicBlock *BB, llvm::SmallPtrSet< llvm::BasicBlock *, 10 > &V)
void Visit(PTR(Stmt) S, ParamTys... P)
llvm::Module & getModule() const
SourceLocation getEndLoc() const LLVM_READONLY
static llvm::FunctionCallee getSehTryEndFn(CodeGenModule &CGM)
EHScopeStack::stable_iterator getEnclosingEHScope() const
bool empty() const
Determines whether the exception-scopes stack is empty.
llvm::AllocaInst * EHSelectorSlot
The selector slot.
static void emitCatchDispatchBlock(CodeGenFunction &CGF, EHCatchScope &catchScope)
Emit the structure of the dispatch block for the given catch scope.
bool Load(InterpState &S, CodePtr OpPC)
bool Zero(InterpState &S, CodePtr OpPC)
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
Represents a variable declaration or definition.
static llvm::Constant * getCatchAllValue(CodeGenFunction &CGF)
Returns the value to inject into a selector to indicate the presence of a catch-all.
llvm::Value * ExceptionSlot
The exception slot.
@ WatchOS
'watchos' is a variant of iOS for Apple's watchOS.
llvm::Function * GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF, const SEHFinallyStmt &Finally)
bool IsOutlinedSEHHelper
True if the current function is an outlined SEH helper.
CodeGenTypes & getTypes()
bool hasSjLjExceptions() const
void clearHandlerBlocks()
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void ExitSEHTryStmt(const SEHTryStmt &S)
virtual void emitBeginCatch(CodeGenFunction &CGF, const CXXCatchStmt *C)=0
llvm::LLVMContext & getLLVMContext()
void pushTerminate()
Push a terminate handler on the stack.
ASTContext & getContext() const
iterator end() const
Returns an iterator pointing to the outermost EH scope.
@ NormalCleanup
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
CXXTryStmt - A C++ try block, including all handlers.
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
static llvm::FunctionCallee getCatchallRethrowFn(CodeGenModule &CGM, StringRef Name)
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
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...
static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn)
Check whether a personality function could reasonably be swapped for a C++ personality function.
bool requiresLandingPad() const
llvm::BasicBlock * getEHDispatchBlock(EHScopeStack::stable_iterator scope)
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
void EmitAnyExprToMem(const Expr *E, Address Location, Qualifiers Quals, bool IsInitializer)
EmitAnyExprToMem - Emits the code necessary to evaluate an arbitrary expression into the given memory...
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
const TargetInfo & getTarget() const
static const EHPersonality GNU_CPlusPlus
@ ObjFW
'objfw' is the Objective-C runtime included in ObjFW
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void EmitSEHTryStmt(const SEHTryStmt &S)
llvm::IntegerType * Int32Ty
bool isObjCObjectPointerType() const
void popFilter()
Pops an exceptions filter off the stack.
virtual llvm::CallInst * emitTerminateForUnexpectedException(CodeGenFunction &CGF, llvm::Value *Exn)
CanQualType UnsignedCharTy
static const EHPersonality & getCPersonality(const TargetInfo &Target, const LangOptions &L)
void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block)
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
const llvm::DataLayout & getDataLayout() const
static llvm::Constant * getOpaquePersonalityFn(CodeGenModule &CGM, const EHPersonality &Personality)
static bool LandingPadHasOnlyCXXUses(llvm::LandingPadInst *LPI)
Check whether a landingpad instruction only uses C++ features.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
LValue - This represents an lvalue references.
llvm::Value * getSelectorFromSlot()
bool usesSEHTry() const
Indicates the function uses __try.
bool isPointerType() const
llvm::FunctionCallee getTerminateFn()
Get the declaration of std::terminate for the platform.
llvm::Function * GenerateSEHFilterFunction(CodeGenFunction &ParentCGF, const SEHExceptStmt &Except)
Create a stub filter function that will ultimately hold the code of the filter expression.
llvm::Value * getPointer() const
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
@ GNUstep
'gnustep' is the modern non-fragile GNUstep runtime.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Expr * getFilterExpr() const
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
CGCXXABI & getCXXABI() const
Represents a prototype with parameter type info, e.g.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
This class organizes the cross-function state that is used while generating LLVM code.
Address withPointer(llvm::Value *NewPointer) const
Return address with different pointer, but same element type and alignment.
Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF, Address ParentVar, llvm::Value *ParentFP)
Recovers the address of a local in a parent function.
llvm::Value * getExceptionFromSlot()
Returns the contents of the function's exception object and selector slots.
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
Decl - This represents one declaration (or definition), e.g.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
llvm::LoadInst * CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
static const EHPersonality & getCXXPersonality(const TargetInfo &Target, const LangOptions &L)
FunctionArgList - Type for representing both the decl and type of parameters to a function.
const Expr * getSubExpr() const
llvm::BasicBlock * getUnreachableBlock()
static const EHPersonality MSVC_except_handler
CodeGenFunction * ParentCGF
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
llvm::Type * ConvertType(QualType T)
llvm::BasicBlock * getEHResumeBlock(bool isCleanup)
llvm::BasicBlock * getCachedEHDispatchBlock() const
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
The basic abstraction for the target Objective-C runtime.
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
llvm::CallBase * EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
static const EHPersonality MSVC_C_specific_handler
static void emitFilterDispatchBlock(CodeGenFunction &CGF, EHFilterScope &filterScope)
Emit the dispatch block for a filter scope if necessary.
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void EmitAnyExprToExn(const Expr *E, Address Addr)
CGFunctionInfo - Class to encapsulate the information about a function definition.
An exceptions scope which filters exceptions thrown through it.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
virtual void mangleSEHFilterExpression(const NamedDecl *EnclosingDecl, raw_ostream &Out)=0
Represents the this expression in C++.
stable_iterator getInnermostEHScope() const
virtual void mangleSEHFinallyBlock(const NamedDecl *EnclosingDecl, raw_ostream &Out)=0
void popCatch()
Pops a catch scope off the stack. This is private to CGException.cpp.
The exceptions personality for a function.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
llvm::StoreInst * CreateFlagStore(bool Value, llvm::Value *Addr)
Emit a store to an i1 flag variable.
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
static RValue get(llvm::Value *V)
Smart pointer class that efficiently represents Objective-C method names.
static bool isNonEHScope(const EHScope &S)
Check whether this is a non-EH scope, i.e.
Stmt - This represents one statement.
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...
A non-stable pointer into the scope stack.
void ForceCleanup(std::initializer_list< llvm::Value ** > ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
CXXCatchStmt - This represents a C++ catch block.
static llvm::FunctionCallee getSehTryBeginFn(CodeGenModule &CGM)
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
static const EHPersonality MSVC_CxxFrameHandler3
DiagnosticsEngine & getDiags() const
SourceLocation getBeginLoc() const LLVM_READONLY
llvm::BasicBlock * getFuncletEHDispatchBlock(EHScopeStack::stable_iterator scope)
FieldDecl * LambdaThisCaptureField
void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter, const Stmt *OutlinedStmt)
Arrange a function prototype that can be called by Windows exception handling personalities.
static void emitWasmCatchPadBlock(CodeGenFunction &CGF, EHCatchScope &CatchScope)
unsigned getNumFilters() const
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
llvm::Instruction * CurrentFuncletPad
static llvm::FunctionCallee getFreeExceptionFn(CodeGenModule &CGM)
void EnterSEHTryStmt(const SEHTryStmt &S)
void EmitStartEHSpec(const Decl *D)
EmitStartEHSpec - Emit the start of the exception spec.
llvm::Constant * tryEmitAbstract(const Expr *E, QualType T)
Try to emit the result of the given expression as an abstract constant.
@ iOS
'ios' is the Apple-provided NeXT-derived runtime on iOS or the iOS simulator; it is always non-fragil...
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
Address getNormalCleanupDestSlot()
llvm::BasicBlock * getTerminateFunclet()
getTerminateLandingPad - Return a cleanup funclet that just calls terminate.
static const EHPersonality XL_CPlusPlus
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void EmitStopPoint(const Stmt *S)
EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
Address CreateMemTemp(QualType T, const Twine &Name="tmp", Address *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
This represents one expression.
CompoundStmt * getBlock() const
void exit(CodeGenFunction &CGF)
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
llvm::Value * getFilter(unsigned i) const
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
llvm::PointerType * VoidPtrPtrTy
SourceLocation getLocation() const
CallArgList - Type for representing both the value and type of arguments in a call.
virtual llvm::Constant * GetEHType(QualType T)=0
Get the type constant to catch for the given ObjC pointer type.
const CGFunctionInfo & arrangeBuiltinFunctionCall(QualType resultType, const CallArgList &args)
A reference to a declared variable, function, enum, etc.
Represents a function declaration or definition.
void popTerminate()
Pops a terminate handler off the stack.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
AllocaInsertPoint - This is an instruction in the entry block before which we prefer to insert alloca...
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
static const EHPersonality GNU_CPlusPlus_SJLJ
llvm::LLVMContext & getLLVMContext()
A saved depth on the scope stack.
const LangOptions & getLangOpts() const
void EmitSEHLeaveStmt(const SEHLeaveStmt &S)
static const EHPersonality GNU_ObjC_SJLJ
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
llvm::BasicBlock * EmitLandingPad()
Emits a landing pad for the current EH stack.
void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock=false)
@ Other
Other implicit parameter.
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
Represents a __leave statement.
static const EHPersonality GNU_ObjC
unsigned getNumExceptions() const
Return the number of types in the exception specification.
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.