#include "CGCXXABI.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/RecordLayout.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/CodeGen/ConstantInitBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/Format.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include <algorithm>
#include <cstdio>
#include <utility>
usingnamespaceclang;
usingnamespaceCodeGen;
CodeGenVTables::CodeGenVTables(CodeGenModule &CGM)
: … { … }
llvm::Constant *CodeGenModule::GetAddrOfThunk(StringRef Name, llvm::Type *FnTy,
GlobalDecl GD) { … }
static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
llvm::Function *ThunkFn, bool ForVTable,
GlobalDecl GD) { … }
#ifndef NDEBUG
static bool similar(const ABIArgInfo &infoL, CanQualType typeL,
const ABIArgInfo &infoR, CanQualType typeR) {
return (infoL.getKind() == infoR.getKind() &&
(typeL == typeR ||
(isa<PointerType>(typeL) && isa<PointerType>(typeR)) ||
(isa<ReferenceType>(typeL) && isa<ReferenceType>(typeR))));
}
#endif
static RValue PerformReturnAdjustment(CodeGenFunction &CGF,
QualType ResultType, RValue RV,
const ThunkInfo &Thunk) { … }
static void resolveTopLevelMetadata(llvm::Function *Fn,
llvm::ValueToValueMapTy &VMap) { … }
llvm::Function *
CodeGenFunction::GenerateVarArgsThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
GlobalDecl GD, const ThunkInfo &Thunk) { … }
void CodeGenFunction::StartThunk(llvm::Function *Fn, GlobalDecl GD,
const CGFunctionInfo &FnInfo,
bool IsUnprototyped) { … }
void CodeGenFunction::FinishThunk() { … }
void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
const ThunkInfo *Thunk,
bool IsUnprototyped) { … }
void CodeGenFunction::EmitMustTailThunk(GlobalDecl GD,
llvm::Value *AdjustedThisPtr,
llvm::FunctionCallee Callee) { … }
void CodeGenFunction::generateThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo, GlobalDecl GD,
const ThunkInfo &Thunk,
bool IsUnprototyped) { … }
static bool shouldEmitVTableThunk(CodeGenModule &CGM, const CXXMethodDecl *MD,
bool IsUnprototyped, bool ForVTable) { … }
llvm::Constant *CodeGenVTables::maybeEmitThunk(GlobalDecl GD,
const ThunkInfo &TI,
bool ForVTable) { … }
void CodeGenVTables::EmitThunks(GlobalDecl GD) { … }
void CodeGenVTables::addRelativeComponent(ConstantArrayBuilder &builder,
llvm::Constant *component,
unsigned vtableAddressPoint,
bool vtableHasLocalLinkage,
bool isCompleteDtor) const { … }
static bool UseRelativeLayout(const CodeGenModule &CGM) { … }
bool CodeGenVTables::useRelativeLayout() const { … }
llvm::Type *CodeGenModule::getVTableComponentType() const { … }
llvm::Type *CodeGenVTables::getVTableComponentType() const { … }
static void AddPointerLayoutOffset(const CodeGenModule &CGM,
ConstantArrayBuilder &builder,
CharUnits offset) { … }
static void AddRelativeLayoutOffset(const CodeGenModule &CGM,
ConstantArrayBuilder &builder,
CharUnits offset) { … }
void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
const VTableLayout &layout,
unsigned componentIndex,
llvm::Constant *rtti,
unsigned &nextVTableThunkIndex,
unsigned vtableAddressPoint,
bool vtableHasLocalLinkage) { … }
llvm::Type *CodeGenVTables::getVTableType(const VTableLayout &layout) { … }
void CodeGenVTables::createVTableInitializer(ConstantStructBuilder &builder,
const VTableLayout &layout,
llvm::Constant *rtti,
bool vtableHasLocalLinkage) { … }
llvm::GlobalVariable *CodeGenVTables::GenerateConstructionVTable(
const CXXRecordDecl *RD, const BaseSubobject &Base, bool BaseIsVirtual,
llvm::GlobalVariable::LinkageTypes Linkage,
VTableAddressPointsMapTy &AddressPoints) { … }
void CodeGenVTables::RemoveHwasanMetadata(llvm::GlobalValue *GV) const { … }
void CodeGenVTables::GenerateRelativeVTableAlias(llvm::GlobalVariable *VTable,
llvm::StringRef AliasNameRef) { … }
static bool shouldEmitAvailableExternallyVTable(const CodeGenModule &CGM,
const CXXRecordDecl *RD) { … }
llvm::GlobalVariable::LinkageTypes
CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { … }
void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) { … }
void
CodeGenVTables::GenerateClassData(const CXXRecordDecl *RD) { … }
bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) { … }
static bool shouldEmitVTableAtEndOfTranslationUnit(CodeGenModule &CGM,
const CXXRecordDecl *RD) { … }
void CodeGenModule::EmitDeferredVTables() { … }
bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) { … }
bool CodeGenModule::HasHiddenLTOVisibility(const CXXRecordDecl *RD) { … }
llvm::GlobalObject::VCallVisibility CodeGenModule::GetVCallVisibilityLevel(
const CXXRecordDecl *RD, llvm::DenseSet<const CXXRecordDecl *> &Visited) { … }
void CodeGenModule::EmitVTableTypeMetadata(const CXXRecordDecl *RD,
llvm::GlobalVariable *VTable,
const VTableLayout &VTLayout) { … }