clang API Documentation
#include "CodeGenFunction.h"
#include "CGCleanup.h"
#include "CGObjCRuntime.h"
#include "TargetInfo.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Intrinsics.h"
Go to the source code of this file.
Functions | |
static llvm::Constant * | getAllocateExceptionFn (CodeGenModule &CGM) |
static llvm::Constant * | getFreeExceptionFn (CodeGenModule &CGM) |
static llvm::Constant * | getThrowFn (CodeGenModule &CGM) |
static llvm::Constant * | getReThrowFn (CodeGenModule &CGM) |
static llvm::Constant * | getGetExceptionPtrFn (CodeGenModule &CGM) |
static llvm::Constant * | getBeginCatchFn (CodeGenModule &CGM) |
static llvm::Constant * | getEndCatchFn (CodeGenModule &CGM) |
static llvm::Constant * | getUnexpectedFn (CodeGenModule &CGM) |
static llvm::Constant * | getTerminateFn (CodeGenModule &CGM) |
static llvm::Constant * | getCatchallRethrowFn (CodeGenModule &CGM, StringRef Name) |
static bool | useLibGCCSEHPersonality (const llvm::Triple &T) |
static const EHPersonality & | getCPersonality (const llvm::Triple &T, const LangOptions &L) |
static const EHPersonality & | getObjCPersonality (const llvm::Triple &T, const LangOptions &L) |
static const EHPersonality & | getCXXPersonality (const llvm::Triple &T, const LangOptions &L) |
static const EHPersonality & | getObjCXXPersonality (const llvm::Triple &T, const LangOptions &L) |
static llvm::Constant * | getPersonalityFn (CodeGenModule &CGM, const EHPersonality &Personality) |
static llvm::Constant * | getOpaquePersonalityFn (CodeGenModule &CGM, const EHPersonality &Personality) |
static bool | PersonalityHasOnlyCXXUses (llvm::Constant *Fn) |
static llvm::Constant * | getCatchAllValue (CodeGenFunction &CGF) |
static void | EmitAnyExprToExn (CodeGenFunction &CGF, const Expr *e, llvm::Value *addr) |
static void | emitFilterDispatchBlock (CodeGenFunction &CGF, EHFilterScope &filterScope) |
Emit the dispatch block for a filter scope if necessary. | |
static bool | isNonEHScope (const EHScope &S) |
static llvm::Value * | CallBeginCatch (CodeGenFunction &CGF, llvm::Value *Exn, bool EndMightThrow) |
static void | InitCatchParam (CodeGenFunction &CGF, const VarDecl &CatchParam, llvm::Value *ParamAddr, SourceLocation Loc) |
static void | BeginCatch (CodeGenFunction &CGF, const CXXCatchStmt *S) |
static void | emitCatchDispatchBlock (CodeGenFunction &CGF, EHCatchScope &catchScope) |
static bool | useClangCallTerminate (CodeGenModule &CGM) |
static llvm::Constant * | getClangCallTerminateFn (CodeGenModule &CGM) |
static void BeginCatch | ( | CodeGenFunction & | CGF, |
const CXXCatchStmt * | S | ||
) | [static] |
Begins a catch statement by initializing the catch variable and calling __cxa_begin_catch.
Definition at line 1090 of file CGException.cpp.
References CallBeginCatch(), clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(), clang::CodeGen::CodeGenFunction::EmitAutoVarCleanups(), clang::CXXCatchStmt::getExceptionDecl(), clang::CodeGen::CodeGenFunction::getExceptionFromSlot(), clang::CXXCatchStmt::getLocStart(), clang::CodeGen::CodeGenFunction::AutoVarEmission::getObjectAddress(), and InitCatchParam().
Referenced by clang::CodeGen::CodeGenFunction::ExitCXXTryStmt().
static llvm::Value* CallBeginCatch | ( | CodeGenFunction & | CGF, |
llvm::Value * | Exn, | ||
bool | EndMightThrow | ||
) | [static] |
Emits a call to __cxa_begin_catch and enters a cleanup to call __cxa_end_catch.
EndMightThrow | - true if __cxa_end_catch might throw |
Definition at line 902 of file CGException.cpp.
References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::EHStack, clang::CodeGen::CodeGenFunction::EmitNounwindRuntimeCall(), getBeginCatchFn(), and clang::CodeGen::NormalAndEHCleanup.
Referenced by BeginCatch(), and InitCatchParam().
static void EmitAnyExprToExn | ( | CodeGenFunction & | CGF, |
const Expr * | e, | ||
llvm::Value * | addr | ||
) | [static] |
Definition at line 380 of file CGException.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::CodeGen::CodeGenFunction::DeactivateCleanupBlock(), clang::CodeGen::EHCleanup, clang::CodeGen::CodeGenFunction::EHStack, clang::CodeGen::CodeGenFunction::EmitAnyExprToMem(), clang::QualType::getQualifiers(), clang::Expr::getType(), clang::CodeGen::CodeGenFunction::pushFullExprCleanup(), and clang::CodeGen::EHScopeStack::stable_begin().
Referenced by clang::CodeGen::CodeGenFunction::EmitCXXThrowExpr().
static void emitCatchDispatchBlock | ( | CodeGenFunction & | CGF, |
EHCatchScope & | catchScope | ||
) | [static] |
Emit the structure of the dispatch block for the given catch scope. It is an invariant that the dispatch block already exists.
Definition at line 1129 of file CGException.cpp.
References clang::CodeGen::EHCatchScope::Handler::Block, clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::createBasicBlock(), clang::CodeGen::CodeGenFunction::EmitBlock(), clang::CodeGen::CodeGenFunction::EmitBlockAfterUses(), clang::CodeGen::EHScope::getCachedEHDispatchBlock(), clang::CodeGen::CodeGenFunction::getEHDispatchBlock(), clang::CodeGen::EHScope::getEnclosingEHScope(), clang::CodeGen::EHCatchScope::getHandler(), clang::CodeGen::CodeGenModule::getIntrinsic(), clang::CodeGen::EHCatchScope::getNumHandlers(), clang::CodeGen::CodeGenFunction::getSelectorFromSlot(), clang::CodeGen::CodeGenTypeCache::Int8PtrTy, clang::CodeGen::EHCatchScope::Handler::isCatchAll(), and clang::CodeGen::EHCatchScope::Handler::Type.
Referenced by clang::CodeGen::CodeGenFunction::ExitCXXTryStmt(), and clang::CodeGen::CodeGenFunction::popCatchScope().
static void emitFilterDispatchBlock | ( | CodeGenFunction & | CGF, |
EHFilterScope & | filterScope | ||
) | [static] |
Emit the dispatch block for a filter scope if necessary.
Definition at line 534 of file CGException.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::createBasicBlock(), clang::CodeGen::CodeGenFunction::EmitBlock(), clang::CodeGen::CodeGenFunction::EmitBlockAfterUses(), clang::CodeGen::CodeGenFunction::EmitRuntimeCall(), clang::CodeGen::EHScope::getCachedEHDispatchBlock(), clang::CodeGen::CodeGenFunction::getEHResumeBlock(), clang::CodeGen::CodeGenFunction::getExceptionFromSlot(), clang::CodeGen::EHFilterScope::getNumFilters(), clang::CodeGen::CodeGenFunction::getSelectorFromSlot(), and getUnexpectedFn().
Referenced by clang::CodeGen::CodeGenFunction::EmitEndEHSpec().
static llvm::Constant* getAllocateExceptionFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 26 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), clang::CodeGen::CodeGenTypeCache::Int8PtrTy, and clang::CodeGen::CodeGenTypeCache::SizeTy.
Referenced by clang::CodeGen::CodeGenFunction::EmitCXXThrowExpr().
static llvm::Constant* getBeginCatchFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 73 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), and clang::CodeGen::CodeGenTypeCache::Int8PtrTy.
Referenced by CallBeginCatch(), and getClangCallTerminateFn().
static llvm::Constant* getCatchallRethrowFn | ( | CodeGenModule & | CGM, |
StringRef | Name | ||
) | [static] |
Definition at line 119 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), clang::CodeGen::CodeGenTypeCache::Int8PtrTy, and clang::CodeGen::CodeGenTypeCache::VoidTy.
Referenced by clang::CodeGen::CodeGenFunction::getEHResumeBlock().
static llvm::Constant* getCatchAllValue | ( | CodeGenFunction & | CGF | ) | [static] |
Returns the value to inject into a selector to indicate the presence of a catch-all.
Definition at line 359 of file CGException.cpp.
References clang::CodeGen::CodeGenTypeCache::Int8PtrTy.
Referenced by clang::CodeGen::CodeGenFunction::EmitLandingPad(), and clang::CodeGen::CodeGenFunction::getTerminateLandingPad().
static llvm::Constant* getClangCallTerminateFn | ( | CodeGenModule & | CGM | ) | [static] |
Get or define the following function: void (i8* exn) nounwind noreturn This code is used only in C++.
Definition at line 1508 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), getBeginCatchFn(), clang::CodeGen::CodeGenModule::getLLVMContext(), clang::CodeGen::CodeGenTypeCache::getRuntimeCC(), getTerminateFn(), clang::HiddenVisibility, clang::CodeGen::CodeGenTypeCache::Int8PtrTy, and clang::CodeGen::CodeGenTypeCache::VoidTy.
Referenced by clang::CodeGen::CodeGenFunction::getTerminateHandler(), and clang::CodeGen::CodeGenFunction::getTerminateLandingPad().
static const EHPersonality& getCPersonality | ( | const llvm::Triple & | T, |
const LangOptions & | L | ||
) | [static] |
Definition at line 177 of file CGException.cpp.
References useLibGCCSEHPersonality().
Referenced by getObjCPersonality().
static const EHPersonality& getCXXPersonality | ( | const llvm::Triple & | T, |
const LangOptions & | L | ||
) | [static] |
Definition at line 205 of file CGException.cpp.
References useLibGCCSEHPersonality().
Referenced by getObjCXXPersonality().
static llvm::Constant* getEndCatchFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 82 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), and clang::CodeGen::CodeGenTypeCache::VoidTy.
static llvm::Constant* getFreeExceptionFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 35 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), clang::CodeGen::CodeGenTypeCache::Int8PtrTy, and clang::CodeGen::CodeGenTypeCache::VoidTy.
static llvm::Constant* getGetExceptionPtrFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 64 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), and clang::CodeGen::CodeGenTypeCache::Int8PtrTy.
Referenced by InitCatchParam().
static const EHPersonality& getObjCPersonality | ( | const llvm::Triple & | T, |
const LangOptions & | L | ||
) | [static] |
Definition at line 186 of file CGException.cpp.
References clang::ObjCRuntime::FragileMacOSX, clang::ObjCRuntime::GCC, getCPersonality(), clang::ObjCRuntime::getKind(), clang::ObjCRuntime::getVersion(), clang::ObjCRuntime::GNUstep, clang::ObjCRuntime::iOS, clang::ObjCRuntime::MacOSX, clang::LangOptions::ObjCRuntime, and clang::ObjCRuntime::ObjFW.
static const EHPersonality& getObjCXXPersonality | ( | const llvm::Triple & | T, |
const LangOptions & | L | ||
) | [static] |
Determines the personality function to use when both C++ and Objective-C exceptions are being caught.
Definition at line 216 of file CGException.cpp.
References clang::ObjCRuntime::FragileMacOSX, clang::ObjCRuntime::GCC, getCXXPersonality(), clang::ObjCRuntime::getKind(), clang::ObjCRuntime::GNUstep, clang::ObjCRuntime::iOS, clang::ObjCRuntime::MacOSX, clang::LangOptions::ObjCRuntime, and clang::ObjCRuntime::ObjFW.
static llvm::Constant* getOpaquePersonalityFn | ( | CodeGenModule & | CGM, |
const EHPersonality & | Personality | ||
) | [static] |
Definition at line 263 of file CGException.cpp.
References getPersonalityFn(), and clang::CodeGen::CodeGenTypeCache::Int8PtrTy.
Referenced by clang::CodeGen::CodeGenFunction::EmitLandingPad(), and clang::CodeGen::CodeGenFunction::getTerminateLandingPad().
static llvm::Constant* getPersonalityFn | ( | CodeGenModule & | CGM, |
const EHPersonality & | Personality | ||
) | [static] |
Definition at line 255 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), and clang::CodeGen::CodeGenTypeCache::Int32Ty.
Referenced by getOpaquePersonalityFn().
static llvm::Constant* getReThrowFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 55 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), and clang::CodeGen::CodeGenTypeCache::VoidTy.
Referenced by clang::CodeGen::CodeGenFunction::EmitCXXThrowExpr(), and clang::CodeGen::CodeGenFunction::ExitCXXTryStmt().
static llvm::Constant* getTerminateFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 100 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::ObjCRuntime::hasTerminate(), clang::LangOptions::ObjCRuntime, and clang::CodeGen::CodeGenTypeCache::VoidTy.
Referenced by getClangCallTerminateFn(), clang::CodeGen::CodeGenFunction::getTerminateHandler(), and clang::CodeGen::CodeGenFunction::getTerminateLandingPad().
static llvm::Constant* getThrowFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 44 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), clang::CodeGen::CodeGenTypeCache::Int8PtrTy, and clang::CodeGen::CodeGenTypeCache::VoidTy.
Referenced by clang::CodeGen::CodeGenFunction::EmitCXXThrowExpr().
static llvm::Constant* getUnexpectedFn | ( | CodeGenModule & | CGM | ) | [static] |
Definition at line 91 of file CGException.cpp.
References clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), clang::CodeGen::CodeGenTypeCache::Int8PtrTy, and clang::CodeGen::CodeGenTypeCache::VoidTy.
Referenced by emitFilterDispatchBlock().
static void InitCatchParam | ( | CodeGenFunction & | CGF, |
const VarDecl & | CatchParam, | ||
llvm::Value * | ParamAddr, | ||
SourceLocation | Loc | ||
) | [static] |
A "special initializer" callback for initializing a catch parameter during catch initialization.
Definition at line 915 of file CGException.cpp.
References clang::CodeGen::CodeGenFunction::Builder, CallBeginCatch(), clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::CodeGen::CodeGenFunction::CreateTempAlloca(), clang::CodeGen::AggValueSlot::DoesNotNeedGCBarriers, clang::CodeGen::CodeGenFunction::EHStack, clang::CodeGen::CodeGenFunction::EmitAggExpr(), clang::CodeGen::CodeGenFunction::EmitAggregateCopy(), clang::CodeGen::CodeGenFunction::EmitARCInitWeak(), clang::CodeGen::CodeGenFunction::EmitARCRetainNonBlock(), clang::CodeGen::CodeGenFunction::EmitLoadOfComplex(), clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(), clang::CodeGen::CodeGenFunction::EmitNounwindRuntimeCall(), clang::CodeGen::CodeGenFunction::EmitStoreOfComplex(), clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(), clang::OpaqueValueExpr::findInCopyConstruct(), clang::CodeGen::AggValueSlot::forAddr(), clang::ASTContext::getCanonicalType(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenFunction::getContext(), clang::ASTContext::getDeclAlign(), getElementType(), clang::CodeGen::CodeGenFunction::getEvaluationKind(), clang::CodeGen::CodeGenFunction::getExceptionFromSlot(), getGetExceptionPtrFn(), clang::VarDecl::getInit(), clang::Qualifiers::getObjCLifetime(), clang::Type::getPointeeType(), clang::CanQual< T >::getQualifiers(), clang::TargetCodeGenInfo::getSizeOfUnwindException(), clang::CodeGen::CodeGenModule::getTargetCodeGenInfo(), clang::ValueDecl::getType(), clang::CodeGen::AggValueSlot::IsNotAliased, clang::CodeGen::AggValueSlot::IsNotDestructed, clang::Type::isRecordType(), clang::CodeGen::CodeGenFunction::MakeAddrLValue(), clang::CodeGen::CodeGenFunction::MakeNaturalAlignAddrLValue(), clang::Qualifiers::OCL_Autoreleasing, clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, clang::Qualifiers::OCL_Weak, clang::CodeGen::CodeGenFunction::OpaqueValueMapping::pop(), clang::CodeGen::EHScopeStack::popTerminate(), clang::CodeGen::EHScopeStack::pushTerminate(), clang::CodeGen::TEK_Aggregate, clang::CodeGen::TEK_Complex, and clang::CodeGen::TEK_Scalar.
Referenced by BeginCatch().
static bool isNonEHScope | ( | const EHScope & | S | ) | [static] |
Check whether this is a non-EH scope, i.e. a scope which doesn't affect exception handling. Currently, the only non-EH scopes are normal-only cleanup scopes.
Definition at line 689 of file CGException.cpp.
References clang::CodeGen::EHScope::Catch, clang::CodeGen::EHScope::Cleanup, clang::CodeGen::EHScope::Filter, clang::CodeGen::EHScope::getKind(), S, and clang::CodeGen::EHScope::Terminate.
Referenced by clang::CodeGen::CodeGenFunction::getInvokeDestImpl().
static bool PersonalityHasOnlyCXXUses | ( | llvm::Constant * | Fn | ) | [static] |
Check whether a personality function could reasonably be swapped for a C++ personality function.
Definition at line 271 of file CGException.cpp.
static bool useClangCallTerminate | ( | CodeGenModule & | CGM | ) | [static] |
In a terminate landing pad, should we use __clang__call_terminate or just a naked call to std::terminate?
__clang_call_terminate calls __cxa_begin_catch, which then allows std::terminate to usefully report something about the violating exception.
Definition at line 1499 of file CGException.cpp.
References clang::TargetInfo::getCXXABI(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::CodeGen::CodeGenModule::getTarget(), and clang::TargetCXXABI::isItaniumFamily().
Referenced by clang::CodeGen::CodeGenFunction::getTerminateHandler(), and clang::CodeGen::CodeGenFunction::getTerminateLandingPad().
static bool useLibGCCSEHPersonality | ( | const llvm::Triple & | T | ) | [static] |
On Win64, use libgcc's SEH personality function. We fall back to dwarf on other platforms, unless the user asked for SjLj exceptions.
Definition at line 173 of file CGException.cpp.
Referenced by getCPersonality(), and getCXXPersonality().