clang 24.0.0git
ItaniumCXXABI.cpp File Reference
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGDebugInfo.h"
#include "CGRecordLayout.h"
#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/Type.h"
#include "clang/Basic/PointerAuthOptions.h"
#include "clang/CodeGen/ConstantInitBuilder.h"
#include "clang/CodeGenUtils/ItaniumCXXABIUtils.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/ConvertEBCDIC.h"
#include "llvm/Support/ScopedPrinter.h"
#include <optional>
#include "clang/AST/TypeNodes.inc"

Go to the source code of this file.

Macros

#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base)
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base)

Functions

static llvm::Constant * pointerAuthResignConstant (llvm::Value *Ptr, const CGPointerAuthInfo &CurAuthInfo, const CGPointerAuthInfo &NewAuthInfo, CodeGenModule &CGM)
static llvm::Constant * pointerAuthResignMemberFunctionPointer (llvm::Constant *Src, QualType DestType, QualType SrcType, CodeGenModule &CGM)
static llvm::FunctionCallee getAllocateExceptionFn (CodeGenModule &CGM)
static llvm::FunctionCallee getThrowFn (CodeGenModule &CGM)
static llvm::FunctionCallee getItaniumDynamicCastFn (CodeGenFunction &CGF)
static llvm::FunctionCallee getBadCastFn (CodeGenFunction &CGF)
static llvm::FunctionCallee getBadTypeidFn (CodeGenFunction &CGF)
template<typename T>
static bool CXXRecordNonInlineHasAttr (const CXXRecordDecl *RD)
static void setVTableSelectiveDLLImportExport (CodeGenModule &CGM, llvm::GlobalVariable *VTable, const CXXRecordDecl *RD)
static llvm::Value * performTypeAdjustment (CodeGenFunction &CGF, Address InitialPtr, const CXXRecordDecl *UnadjustedClass, int64_t NonVirtualAdjustment, int64_t VirtualAdjustment, bool IsReturnAdjustment)
static llvm::FunctionCallee getGuardAcquireFn (CodeGenModule &CGM, llvm::PointerType *GuardPtrTy)
static llvm::FunctionCallee getGuardReleaseFn (CodeGenModule &CGM, llvm::PointerType *GuardPtrTy)
static llvm::FunctionCallee getGuardAbortFn (CodeGenModule &CGM, llvm::PointerType *GuardPtrTy)
static void emitGlobalDtorWithCXAAtExit (CodeGenFunction &CGF, llvm::FunctionCallee dtor, llvm::Constant *addr, bool TLS)
 Register a global destructor using __cxa_atexit.
static llvm::Function * createGlobalInitOrCleanupFn (CodeGen::CodeGenModule &CGM, StringRef FnName)
static bool isThreadWrapperReplaceable (const VarDecl *VD, CodeGen::CodeGenModule &CGM)
static llvm::GlobalValue::LinkageTypes getThreadLocalWrapperLinkage (const VarDecl *VD, CodeGen::CodeGenModule &CGM)
 Get the appropriate linkage for the wrapper function.
static bool ShouldUseExternalRTTIDescriptor (CodeGenModule &CGM, QualType Ty)
 ShouldUseExternalRTTIDescriptor - Returns whether the type information for the given type exists somewhere else, and that we should not emit the type information in this translation unit.
static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage (CodeGenModule &CGM, QualType Ty)
 Return the linkage that the type info and type info name constants should have for the given type.
static llvm::GlobalValue::VisibilityTypes getRTTIVisibility (llvm::GlobalValue::VisibilityTypes Visibility, llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass)
 A dllexported global must not be hidden, so dllexport takes precedence over the visibility implied by -fvisibility=hidden, as elsewhere in CodeGen.
static bool structorSymbolMustBeRetained (CodeGenModule &CGM, const CXXMethodDecl *MD, llvm::GlobalValue::LinkageTypes Linkage)
static StructorCodegen getCodegenToUse (CodeGenModule &CGM, const CXXMethodDecl *MD)
static void emitConstructorDestructorAlias (CodeGenModule &CGM, GlobalDecl AliasDecl, GlobalDecl TargetDecl)
static llvm::FunctionCallee getBeginCatchFn (CodeGenModule &CGM)
static llvm::FunctionCallee getEndCatchFn (CodeGenModule &CGM)
static llvm::FunctionCallee getGetExceptionPtrFn (CodeGenModule &CGM)
static llvm::Value * CallBeginCatch (CodeGenFunction &CGF, llvm::Value *Exn, bool EndMightThrow)
 Emits a call to __cxa_begin_catch and enters a cleanup to call __cxa_end_catch.
static void InitCatchParam (CodeGenFunction &CGF, const VarDecl &CatchParam, Address ParamAddr, SourceLocation Loc)
 A "special initializer" callback for initializing a catch parameter during catch initialization.
static llvm::FunctionCallee getClangCallTerminateFn (CodeGenModule &CGM)
 Get or define the following function: void @__clang_call_terminate(i8* exn) nounwind noreturn This code is used only in C++.

Macro Definition Documentation

◆ ABSTRACT_TYPE [1/2]

#define ABSTRACT_TYPE ( Class,
Base )

◆ ABSTRACT_TYPE [2/2]

#define ABSTRACT_TYPE ( Class,
Base )

◆ DEPENDENT_TYPE [1/2]

#define DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ DEPENDENT_TYPE [2/2]

#define DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ NON_CANONICAL_TYPE [1/2]

#define NON_CANONICAL_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ NON_CANONICAL_TYPE [2/2]

#define NON_CANONICAL_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ NON_CANONICAL_UNLESS_DEPENDENT_TYPE [1/2]

#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ NON_CANONICAL_UNLESS_DEPENDENT_TYPE [2/2]

#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE ( Class,
Base )
Value:
case Type::Class:

◆ TYPE [1/2]

#define TYPE ( Class,
Base )

◆ TYPE [2/2]

#define TYPE ( Class,
Base )

Function Documentation

◆ CallBeginCatch()

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.

If -fassume-nothrow-exception-dtor is specified, we assume that the exception object's dtor is nothrow, therefore the __cxa_end_catch call can be marked as nounwind even if EndMightThrow is true.

Parameters
EndMightThrow- true if __cxa_end_catch might throw

Definition at line 4601 of file ItaniumCXXABI.cpp.

References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::EHStack, clang::CodeGen::CodeGenFunction::EmitNounwindRuntimeCall(), getBeginCatchFn(), clang::CodeGen::CodeGenModule::getLangOpts(), and clang::CodeGen::NormalAndEHCleanup.

Referenced by InitCatchParam().

◆ createGlobalInitOrCleanupFn()

◆ CXXRecordNonInlineHasAttr()

◆ emitConstructorDestructorAlias()

◆ emitGlobalDtorWithCXAAtExit()

◆ getAllocateExceptionFn()

◆ getBadCastFn()

◆ getBadTypeidFn()

◆ getBeginCatchFn()

llvm::FunctionCallee getBeginCatchFn ( CodeGenModule & CGM)
static

◆ getClangCallTerminateFn()

◆ getCodegenToUse()

◆ getEndCatchFn()

llvm::FunctionCallee getEndCatchFn ( CodeGenModule & CGM)
static

◆ getGetExceptionPtrFn()

llvm::FunctionCallee getGetExceptionPtrFn ( CodeGenModule & CGM)
static

◆ getGuardAbortFn()

llvm::FunctionCallee getGuardAbortFn ( CodeGenModule & CGM,
llvm::PointerType * GuardPtrTy )
static

◆ getGuardAcquireFn()

◆ getGuardReleaseFn()

llvm::FunctionCallee getGuardReleaseFn ( CodeGenModule & CGM,
llvm::PointerType * GuardPtrTy )
static

◆ getItaniumDynamicCastFn()

◆ getRTTIVisibility()

llvm::GlobalValue::VisibilityTypes getRTTIVisibility ( llvm::GlobalValue::VisibilityTypes Visibility,
llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass )
static

A dllexported global must not be hidden, so dllexport takes precedence over the visibility implied by -fvisibility=hidden, as elsewhere in CodeGen.

Definition at line 3889 of file ItaniumCXXABI.cpp.

◆ getThreadLocalWrapperLinkage()

llvm::GlobalValue::LinkageTypes getThreadLocalWrapperLinkage ( const VarDecl * VD,
CodeGen::CodeGenModule & CGM )
static

Get the appropriate linkage for the wrapper function.

This is essentially the weak form of the variable's linkage; every translation unit which needs the wrapper emits a copy, and we want the linker to merge them.

Definition at line 3118 of file ItaniumCXXABI.cpp.

References clang::CodeGen::CodeGenModule::getLLVMLinkageVarDefinition(), and isThreadWrapperReplaceable().

◆ getThrowFn()

◆ getTypeInfoLinkage()

◆ InitCatchParam()

void InitCatchParam ( CodeGenFunction & CGF,
const VarDecl & CatchParam,
Address ParamAddr,
SourceLocation Loc )
static

A "special initializer" callback for initializing a catch parameter during catch initialization.

Definition at line 4616 of file ItaniumCXXABI.cpp.

References clang::CodeGen::CodeGenFunction::Builder, CallBeginCatch(), clang::cast(), clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::CodeGen::CGBuilderTy::CreateStore(), clang::CodeGen::CodeGenFunction::CreateTempAlloca(), clang::CodeGen::CodeGenTypeCache::DefaultPtrTy, clang::CodeGen::AggValueSlot::DoesNotNeedGCBarriers, clang::CodeGen::AggValueSlot::DoesNotOverlap, 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::Address::emitRawPointer(), clang::CodeGen::CodeGenFunction::EmitStoreOfComplex(), clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(), clang::OpaqueValueExpr::findInCopyConstruct(), clang::CodeGen::AggValueSlot::forAddr(), clang::ASTContext::getCanonicalType(), clang::CodeGen::CodeGenModule::getClassPointerAlignment(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenFunction::getEvaluationKind(), clang::CodeGen::CodeGenFunction::getExceptionFromSlot(), getGetExceptionPtrFn(), clang::VarDecl::getInit(), clang::Qualifiers::getObjCLifetime(), clang::Type::getPointeeType(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CanQual< T >::getQualifiers(), clang::CodeGen::TargetCodeGenInfo::getSizeOfUnwindException(), clang::CodeGen::CodeGenModule::getTargetCodeGenInfo(), clang::ValueDecl::getType(), clang::CodeGen::CodeGenTypeCache::Int8Ty, clang::isa(), 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.

◆ isThreadWrapperReplaceable()

◆ performTypeAdjustment()

◆ pointerAuthResignConstant()

◆ pointerAuthResignMemberFunctionPointer()

◆ setVTableSelectiveDLLImportExport()

void setVTableSelectiveDLLImportExport ( CodeGenModule & CGM,
llvm::GlobalVariable * VTable,
const CXXRecordDecl * RD )
static

◆ ShouldUseExternalRTTIDescriptor()

bool ShouldUseExternalRTTIDescriptor ( CodeGenModule & CGM,
QualType Ty )
static

ShouldUseExternalRTTIDescriptor - Returns whether the type information for the given type exists somewhere else, and that we should not emit the type information in this translation unit.

Assumes that it is not a standard-library type.

Definition at line 3630 of file ItaniumCXXABI.cpp.

References clang::cast(), false, clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getTarget(), clang::CodeGen::CodeGenModule::getTriple(), clang::CodeGen::CodeGenModule::getVTables(), clang::Decl::hasAttr(), clang::CXXRecordDecl::hasDefinition(), clang::TargetInfo::hasPS4DLLImportExport(), clang::CXXRecordDecl::isDynamicClass(), and clang::CodeGen::CodeGenVTables::isVTableExternal().

Referenced by getTypeInfoLinkage().

◆ structorSymbolMustBeRetained()

bool structorSymbolMustBeRetained ( CodeGenModule & CGM,
const CXXMethodDecl * MD,
llvm::GlobalValue::LinkageTypes Linkage )
static