#include "ABIInfoImpl.h"
#include "CGBlocks.h"
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CGRecordLayout.h"
#include "CodeGenFunction.h"
#include "TargetInfo.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Transforms/Utils/SanitizerStats.h"
#include <optional>
usingnamespaceclang;
usingnamespaceCodeGen;
CharUnits CodeGenModule::getClassPointerAlignment(const CXXRecordDecl *RD) { … }
CharUnits CodeGenModule::getMinimumClassObjectSize(const CXXRecordDecl *RD) { … }
CharUnits CodeGenModule::getVBaseAlignment(CharUnits actualDerivedAlign,
const CXXRecordDecl *derivedClass,
const CXXRecordDecl *vbaseClass) { … }
CharUnits
CodeGenModule::getDynamicOffsetAlignment(CharUnits actualBaseAlign,
const CXXRecordDecl *baseDecl,
CharUnits expectedTargetAlign) { … }
Address CodeGenFunction::LoadCXXThisAddress() { … }
Address
CodeGenFunction::EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
llvm::Value *memberPtr,
const MemberPointerType *memberPtrType,
LValueBaseInfo *BaseInfo,
TBAAAccessInfo *TBAAInfo) { … }
CharUnits CodeGenModule::computeNonVirtualBaseClassOffset(
const CXXRecordDecl *DerivedClass, CastExpr::path_const_iterator Start,
CastExpr::path_const_iterator End) { … }
llvm::Constant *
CodeGenModule::GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
CastExpr::path_const_iterator PathBegin,
CastExpr::path_const_iterator PathEnd) { … }
Address
CodeGenFunction::GetAddressOfDirectBaseInCompleteClass(Address This,
const CXXRecordDecl *Derived,
const CXXRecordDecl *Base,
bool BaseIsVirtual) { … }
static Address
ApplyNonVirtualAndVirtualOffset(CodeGenFunction &CGF, Address addr,
CharUnits nonVirtualOffset,
llvm::Value *virtualOffset,
const CXXRecordDecl *derivedClass,
const CXXRecordDecl *nearestVBase) { … }
Address CodeGenFunction::GetAddressOfBaseClass(
Address Value, const CXXRecordDecl *Derived,
CastExpr::path_const_iterator PathBegin,
CastExpr::path_const_iterator PathEnd, bool NullCheckValue,
SourceLocation Loc) { … }
Address
CodeGenFunction::GetAddressOfDerivedClass(Address BaseAddr,
const CXXRecordDecl *Derived,
CastExpr::path_const_iterator PathBegin,
CastExpr::path_const_iterator PathEnd,
bool NullCheckValue) { … }
llvm::Value *CodeGenFunction::GetVTTParameter(GlobalDecl GD,
bool ForVirtualBase,
bool Delegating) { … }
namespace {
struct CallBaseDtor final : EHScopeStack::Cleanup { … };
struct DynamicThisUseChecker : ConstEvaluatedExprVisitor<DynamicThisUseChecker> { … };
}
static bool BaseInitializerUsesThis(ASTContext &C, const Expr *Init) { … }
static void EmitBaseInitializer(CodeGenFunction &CGF,
const CXXRecordDecl *ClassDecl,
CXXCtorInitializer *BaseInit) { … }
static bool isMemcpyEquivalentSpecialMember(const CXXMethodDecl *D) { … }
static void EmitLValueForAnyFieldInitialization(CodeGenFunction &CGF,
CXXCtorInitializer *MemberInit,
LValue &LHS) { … }
static void EmitMemberInitializer(CodeGenFunction &CGF,
const CXXRecordDecl *ClassDecl,
CXXCtorInitializer *MemberInit,
const CXXConstructorDecl *Constructor,
FunctionArgList &Args) { … }
void CodeGenFunction::EmitInitializerForField(FieldDecl *Field, LValue LHS,
Expr *Init) { … }
bool CodeGenFunction::IsConstructorDelegationValid(
const CXXConstructorDecl *Ctor) { … }
void CodeGenFunction::EmitAsanPrologueOrEpilogue(bool Prologue) { … }
void CodeGenFunction::EmitConstructorBody(FunctionArgList &Args) { … }
namespace {
class CopyingValueRepresentation { … };
}
namespace {
class FieldMemcpyizer { … };
class ConstructorMemcpyizer : public FieldMemcpyizer { … };
class AssignmentMemcpyizer : public FieldMemcpyizer { … };
}
static bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit) { … }
void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
CXXCtorType CtorType,
FunctionArgList &Args) { … }
static bool
FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
static bool
HasTrivialDestructorBody(ASTContext &Context,
const CXXRecordDecl *BaseClassDecl,
const CXXRecordDecl *MostDerivedClassDecl)
{ … }
static bool
FieldHasTrivialDestructorBody(ASTContext &Context,
const FieldDecl *Field)
{ … }
static bool CanSkipVTablePointerInitialization(CodeGenFunction &CGF,
const CXXDestructorDecl *Dtor) { … }
void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) { … }
void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &Args) { … }
namespace {
llvm::Value *LoadThisForDtorDelete(CodeGenFunction &CGF,
const CXXDestructorDecl *DD) { … }
struct CallDtorDelete final : EHScopeStack::Cleanup { … };
void EmitConditionalDtorDeleteCall(CodeGenFunction &CGF,
llvm::Value *ShouldDeleteCondition,
bool ReturnAfterDelete) { … }
struct CallDtorDeleteConditional final : EHScopeStack::Cleanup { … };
class DestroyField final : public EHScopeStack::Cleanup { … };
class DeclAsInlineDebugLocation { … };
static void EmitSanitizerDtorCallback(
CodeGenFunction &CGF, StringRef Name, llvm::Value *Ptr,
std::optional<CharUnits::QuantityType> PoisonSize = { … }
static void
EmitSanitizerDtorFieldsCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
CharUnits::QuantityType PoisonSize) { … }
struct SanitizeDtorTrivialBase final : EHScopeStack::Cleanup { … };
class SanitizeDtorFieldRange final : public EHScopeStack::Cleanup { … };
class SanitizeDtorVTable final : public EHScopeStack::Cleanup { … };
class SanitizeDtorCleanupBuilder { … };
}
void CodeGenFunction::EnterDtorCleanups(const CXXDestructorDecl *DD,
CXXDtorType DtorType) { … }
void CodeGenFunction::EmitCXXAggrConstructorCall(
const CXXConstructorDecl *ctor, const ArrayType *arrayType,
Address arrayBegin, const CXXConstructExpr *E, bool NewPointerIsChecked,
bool zeroInitialize) { … }
void CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *ctor,
llvm::Value *numElements,
Address arrayBase,
const CXXConstructExpr *E,
bool NewPointerIsChecked,
bool zeroInitialize) { … }
void CodeGenFunction::destroyCXXObject(CodeGenFunction &CGF,
Address addr,
QualType type) { … }
void CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
CXXCtorType Type,
bool ForVirtualBase,
bool Delegating,
AggValueSlot ThisAVS,
const CXXConstructExpr *E) { … }
static bool canEmitDelegateCallArgs(CodeGenFunction &CGF,
const CXXConstructorDecl *Ctor,
CXXCtorType Type, CallArgList &Args) { … }
void CodeGenFunction::EmitCXXConstructorCall(
const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase,
bool Delegating, Address This, CallArgList &Args,
AggValueSlot::Overlap_t Overlap, SourceLocation Loc,
bool NewPointerIsChecked, llvm::CallBase **CallOrInvoke) { … }
void CodeGenFunction::EmitInheritedCXXConstructorCall(
const CXXConstructorDecl *D, bool ForVirtualBase, Address This,
bool InheritedFromVBase, const CXXInheritedCtorInitExpr *E) { … }
void CodeGenFunction::EmitInlinedInheritingCXXConstructorCall(
const CXXConstructorDecl *Ctor, CXXCtorType CtorType, bool ForVirtualBase,
bool Delegating, CallArgList &Args) { … }
void CodeGenFunction::EmitVTableAssumptionLoad(const VPtr &Vptr, Address This) { … }
void CodeGenFunction::EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl,
Address This) { … }
void
CodeGenFunction::EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D,
Address This, Address Src,
const CXXConstructExpr *E) { … }
void
CodeGenFunction::EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor,
CXXCtorType CtorType,
const FunctionArgList &Args,
SourceLocation Loc) { … }
namespace {
struct CallDelegatingCtorDtor final : EHScopeStack::Cleanup { … };
}
void
CodeGenFunction::EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor,
const FunctionArgList &Args) { … }
void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *DD,
CXXDtorType Type,
bool ForVirtualBase,
bool Delegating, Address This,
QualType ThisTy) { … }
namespace {
struct CallLocalDtor final : EHScopeStack::Cleanup { … };
}
void CodeGenFunction::PushDestructorCleanup(const CXXDestructorDecl *D,
QualType T, Address Addr) { … }
void CodeGenFunction::PushDestructorCleanup(QualType T, Address Addr) { … }
void CodeGenFunction::InitializeVTablePointer(const VPtr &Vptr) { … }
CodeGenFunction::VPtrsVector
CodeGenFunction::getVTablePointers(const CXXRecordDecl *VTableClass) { … }
void CodeGenFunction::getVTablePointers(BaseSubobject Base,
const CXXRecordDecl *NearestVBase,
CharUnits OffsetFromNearestVBase,
bool BaseIsNonVirtualPrimaryBase,
const CXXRecordDecl *VTableClass,
VisitedVirtualBasesSetTy &VBases,
VPtrsVector &Vptrs) { … }
void CodeGenFunction::InitializeVTablePointers(const CXXRecordDecl *RD) { … }
llvm::Value *CodeGenFunction::GetVTablePtr(Address This,
llvm::Type *VTableTy,
const CXXRecordDecl *RD,
VTableAuthMode AuthMode) { … }
static const CXXRecordDecl *
LeastDerivedClassWithSameLayout(const CXXRecordDecl *RD) { … }
void CodeGenFunction::EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD,
llvm::Value *VTable,
SourceLocation Loc) { … }
void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
llvm::Value *VTable,
CFITypeCheckKind TCK,
SourceLocation Loc) { … }
void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T, Address Derived,
bool MayBeNull,
CFITypeCheckKind TCK,
SourceLocation Loc) { … }
void CodeGenFunction::EmitVTablePtrCheck(const CXXRecordDecl *RD,
llvm::Value *VTable,
CFITypeCheckKind TCK,
SourceLocation Loc) { … }
bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) { … }
llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
const CXXRecordDecl *RD, llvm::Value *VTable, llvm::Type *VTableTy,
uint64_t VTableByteOffset) { … }
void CodeGenFunction::EmitForwardingCallToLambda(
const CXXMethodDecl *callOperator, CallArgList &callArgs,
const CGFunctionInfo *calleeFnInfo, llvm::Constant *calleePtr) { … }
void CodeGenFunction::EmitLambdaBlockInvokeBody() { … }
void CodeGenFunction::EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD) { … }
void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD,
CallArgList &CallArgs) { … }
void CodeGenFunction::EmitLambdaInAllocaCallOpBody(const CXXMethodDecl *MD) { … }
void CodeGenFunction::EmitLambdaInAllocaImplFn(
const CXXMethodDecl *CallOp, const CGFunctionInfo **ImplFnInfo,
llvm::Function **ImplFn) { … }