#include "CGBlocks.h"
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGDebugInfo.h"
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
#include "EHScopeStack.h"
#include "PatternInit.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/Sema/Sema.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Type.h"
#include <optional>
usingnamespaceclang;
usingnamespaceCodeGen;
static_assert …;
void CodeGenFunction::EmitDecl(const Decl &D) { … }
void CodeGenFunction::EmitVarDecl(const VarDecl &D) { … }
static std::string getStaticDeclName(CodeGenModule &CGM, const VarDecl &D) { … }
llvm::Constant *CodeGenModule::getOrCreateStaticVarDecl(
const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage) { … }
llvm::GlobalVariable *
CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
llvm::GlobalVariable *GV) { … }
void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
llvm::GlobalValue::LinkageTypes Linkage) { … }
namespace {
struct DestroyObject final : EHScopeStack::Cleanup { … };
template <class Derived>
struct DestroyNRVOVariable : EHScopeStack::Cleanup { … };
struct DestroyNRVOVariableCXX final
: DestroyNRVOVariable<DestroyNRVOVariableCXX> { … };
struct DestroyNRVOVariableC final
: DestroyNRVOVariable<DestroyNRVOVariableC> { … };
struct CallStackRestore final : EHScopeStack::Cleanup { … };
struct KmpcAllocFree final : EHScopeStack::Cleanup { … };
struct ExtendGCLifetime final : EHScopeStack::Cleanup { … };
struct CallCleanupFunction final : EHScopeStack::Cleanup { … };
}
static void EmitAutoVarWithLifetime(CodeGenFunction &CGF, const VarDecl &var,
Address addr,
Qualifiers::ObjCLifetime lifetime) { … }
static bool isAccessedBy(const VarDecl &var, const Stmt *s) { … }
static bool isAccessedBy(const ValueDecl *decl, const Expr *e) { … }
static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF,
const LValue &destLV, const Expr *init) { … }
static void drillIntoBlockVariable(CodeGenFunction &CGF,
LValue &lvalue,
const VarDecl *var) { … }
void CodeGenFunction::EmitNullabilityCheck(LValue LHS, llvm::Value *RHS,
SourceLocation Loc) { … }
void CodeGenFunction::EmitScalarInit(const Expr *init, const ValueDecl *D,
LValue lvalue, bool capturedByInit) { … }
static bool canEmitInitWithFewStoresAfterBZero(llvm::Constant *Init,
unsigned &NumStores) { … }
static void emitStoresForInitAfterBZero(CodeGenModule &CGM,
llvm::Constant *Init, Address Loc,
bool isVolatile, CGBuilderTy &Builder,
bool IsAutoInit) { … }
static bool shouldUseBZeroPlusStoresToInitialize(llvm::Constant *Init,
uint64_t GlobalSize) { … }
static llvm::Value *shouldUseMemSetToInitialize(llvm::Constant *Init,
uint64_t GlobalSize,
const llvm::DataLayout &DL) { … }
static bool shouldSplitConstantStore(CodeGenModule &CGM,
uint64_t GlobalByteSize) { … }
enum class IsPattern { … };
static llvm::Constant *patternOrZeroFor(CodeGenModule &CGM, IsPattern isPattern,
llvm::Type *Ty) { … }
static llvm::Constant *constWithPadding(CodeGenModule &CGM, IsPattern isPattern,
llvm::Constant *constant);
static llvm::Constant *constStructWithPadding(CodeGenModule &CGM,
IsPattern isPattern,
llvm::StructType *STy,
llvm::Constant *constant) { … }
static llvm::Constant *constWithPadding(CodeGenModule &CGM, IsPattern isPattern,
llvm::Constant *constant) { … }
Address CodeGenModule::createUnnamedGlobalFrom(const VarDecl &D,
llvm::Constant *Constant,
CharUnits Align) { … }
static Address createUnnamedGlobalForMemcpyFrom(CodeGenModule &CGM,
const VarDecl &D,
CGBuilderTy &Builder,
llvm::Constant *Constant,
CharUnits Align) { … }
static void emitStoresForConstant(CodeGenModule &CGM, const VarDecl &D,
Address Loc, bool isVolatile,
CGBuilderTy &Builder,
llvm::Constant *constant, bool IsAutoInit) { … }
static void emitStoresForZeroInit(CodeGenModule &CGM, const VarDecl &D,
Address Loc, bool isVolatile,
CGBuilderTy &Builder) { … }
static void emitStoresForPatternInit(CodeGenModule &CGM, const VarDecl &D,
Address Loc, bool isVolatile,
CGBuilderTy &Builder) { … }
static bool containsUndef(llvm::Constant *constant) { … }
static llvm::Constant *replaceUndef(CodeGenModule &CGM, IsPattern isPattern,
llvm::Constant *constant) { … }
void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D) { … }
llvm::Value *CodeGenFunction::EmitLifetimeStart(llvm::TypeSize Size,
llvm::Value *Addr) { … }
void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr) { … }
void CodeGenFunction::EmitAndRegisterVariableArrayDimensions(
CGDebugInfo *DI, const VarDecl &D, bool EmitDebugInfo) { … }
CodeGenFunction::AutoVarEmission
CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { … }
static bool isCapturedBy(const VarDecl &, const Expr *);
static bool isCapturedBy(const VarDecl &Var, const Stmt *S) { … }
static bool isCapturedBy(const VarDecl &Var, const Expr *E) { … }
bool CodeGenFunction::isTrivialInitializer(const Expr *Init) { … }
void CodeGenFunction::emitZeroOrPatternForAutoVarInit(QualType type,
const VarDecl &D,
Address Loc) { … }
void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { … }
void CodeGenFunction::EmitExprAsInit(const Expr *init, const ValueDecl *D,
LValue lvalue, bool capturedByInit) { … }
void CodeGenFunction::emitAutoVarTypeCleanup(
const CodeGenFunction::AutoVarEmission &emission,
QualType::DestructionKind dtorKind) { … }
void CodeGenFunction::EmitAutoVarCleanups(const AutoVarEmission &emission) { … }
CodeGenFunction::Destroyer *
CodeGenFunction::getDestroyer(QualType::DestructionKind kind) { … }
void CodeGenFunction::pushEHDestroy(QualType::DestructionKind dtorKind,
Address addr, QualType type) { … }
void CodeGenFunction::pushDestroy(QualType::DestructionKind dtorKind,
Address addr, QualType type) { … }
void CodeGenFunction::pushDestroy(CleanupKind cleanupKind, Address addr,
QualType type, Destroyer *destroyer,
bool useEHCleanupForArray) { … }
void CodeGenFunction::pushDestroyAndDeferDeactivation(
QualType::DestructionKind dtorKind, Address addr, QualType type) { … }
void CodeGenFunction::pushDestroyAndDeferDeactivation(
CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer,
bool useEHCleanupForArray) { … }
void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) { … }
void CodeGenFunction::pushKmpcAllocFree(
CleanupKind Kind, std::pair<llvm::Value *, llvm::Value *> AddrSizePair) { … }
void CodeGenFunction::pushLifetimeExtendedDestroy(CleanupKind cleanupKind,
Address addr, QualType type,
Destroyer *destroyer,
bool useEHCleanupForArray) { … }
void CodeGenFunction::emitDestroy(Address addr, QualType type,
Destroyer *destroyer,
bool useEHCleanupForArray) { … }
void CodeGenFunction::emitArrayDestroy(llvm::Value *begin,
llvm::Value *end,
QualType elementType,
CharUnits elementAlign,
Destroyer *destroyer,
bool checkZeroLength,
bool useEHCleanup) { … }
static void emitPartialArrayDestroy(CodeGenFunction &CGF,
llvm::Value *begin, llvm::Value *end,
QualType type, CharUnits elementAlign,
CodeGenFunction::Destroyer *destroyer) { … }
namespace {
class RegularPartialArrayDestroy final : public EHScopeStack::Cleanup { … };
class IrregularPartialArrayDestroy final : public EHScopeStack::Cleanup { … };
}
void CodeGenFunction::pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin,
Address arrayEndPointer,
QualType elementType,
CharUnits elementAlign,
Destroyer *destroyer) { … }
void CodeGenFunction::pushRegularPartialArrayCleanup(llvm::Value *arrayBegin,
llvm::Value *arrayEnd,
QualType elementType,
CharUnits elementAlign,
Destroyer *destroyer) { … }
llvm::Function *CodeGenModule::getLLVMLifetimeStartFn() { … }
llvm::Function *CodeGenModule::getLLVMLifetimeEndFn() { … }
namespace {
struct ConsumeARCParameter final : EHScopeStack::Cleanup { … };
}
void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
unsigned ArgNo) { … }
void CodeGenModule::EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D,
CodeGenFunction *CGF) { … }
void CodeGenModule::EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
CodeGenFunction *CGF) { … }
void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) { … }
void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { … }
std::optional<CharUnits>
CodeGenModule::getOMPAllocateAlignment(const VarDecl *VD) { … }