#include "ABIInfoImpl.h"
#include "CGCXXABI.h"
#include "CGObjCRuntime.h"
#include "CGRecordLayout.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
#include "clang/AST/APValue.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Builtins.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include <optional>
usingnamespaceclang;
usingnamespaceCodeGen;
namespace {
class ConstExprEmitter;
struct ConstantAggregateBuilderUtils { … };
class ConstantAggregateBuilder : private ConstantAggregateBuilderUtils { … };
template<typename Container, typename Range = std::initializer_list<
typename Container::value_type>>
static void replace(Container &C, size_t BeginOff, size_t EndOff, Range Vals) { … }
bool ConstantAggregateBuilder::add(llvm::Constant *C, CharUnits Offset,
bool AllowOverwrite) { … }
bool ConstantAggregateBuilder::addBits(llvm::APInt Bits, uint64_t OffsetInBits,
bool AllowOverwrite) { … }
std::optional<size_t> ConstantAggregateBuilder::splitAt(CharUnits Pos) { … }
bool ConstantAggregateBuilder::split(size_t Index, CharUnits Hint) { … }
static llvm::Constant *
EmitArrayConstant(CodeGenModule &CGM, llvm::ArrayType *DesiredType,
llvm::Type *CommonElementType, uint64_t ArrayBound,
SmallVectorImpl<llvm::Constant *> &Elements,
llvm::Constant *Filler);
llvm::Constant *ConstantAggregateBuilder::buildFrom(
CodeGenModule &CGM, ArrayRef<llvm::Constant *> Elems,
ArrayRef<CharUnits> Offsets, CharUnits StartOffset, CharUnits Size,
bool NaturalLayout, llvm::Type *DesiredTy, bool AllowOversized) { … }
void ConstantAggregateBuilder::condense(CharUnits Offset,
llvm::Type *DesiredTy) { … }
class ConstStructBuilder { … };
bool ConstStructBuilder::AppendField(
const FieldDecl *Field, uint64_t FieldOffset, llvm::Constant *InitCst,
bool AllowOverwrite) { … }
bool ConstStructBuilder::AppendBytes(CharUnits FieldOffsetInChars,
llvm::Constant *InitCst,
bool AllowOverwrite) { … }
bool ConstStructBuilder::AppendBitField(const FieldDecl *Field,
uint64_t FieldOffset, llvm::Constant *C,
bool AllowOverwrite) { … }
static bool EmitDesignatedInitUpdater(ConstantEmitter &Emitter,
ConstantAggregateBuilder &Const,
CharUnits Offset, QualType Type,
const InitListExpr *Updater) { … }
bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) { … }
namespace {
struct BaseInfo { … };
}
bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD,
bool IsPrimaryBase,
const CXXRecordDecl *VTableClass,
CharUnits Offset) { … }
llvm::Constant *ConstStructBuilder::Finalize(QualType Type) { … }
llvm::Constant *ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter,
const InitListExpr *ILE,
QualType ValTy) { … }
llvm::Constant *ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter,
const APValue &Val,
QualType ValTy) { … }
bool ConstStructBuilder::UpdateStruct(ConstantEmitter &Emitter,
ConstantAggregateBuilder &Const,
CharUnits Offset,
const InitListExpr *Updater) { … }
static ConstantAddress
tryEmitGlobalCompoundLiteral(ConstantEmitter &emitter,
const CompoundLiteralExpr *E) { … }
static llvm::Constant *
EmitArrayConstant(CodeGenModule &CGM, llvm::ArrayType *DesiredType,
llvm::Type *CommonElementType, uint64_t ArrayBound,
SmallVectorImpl<llvm::Constant *> &Elements,
llvm::Constant *Filler) { … }
class ConstExprEmitter
: public ConstStmtVisitor<ConstExprEmitter, llvm::Constant *, QualType> { … };
}
llvm::Constant *ConstantEmitter::validateAndPopAbstract(llvm::Constant *C,
AbstractState saved) { … }
llvm::Constant *
ConstantEmitter::tryEmitAbstractForInitializer(const VarDecl &D) { … }
llvm::Constant *
ConstantEmitter::tryEmitAbstract(const Expr *E, QualType destType) { … }
llvm::Constant *
ConstantEmitter::tryEmitAbstract(const APValue &value, QualType destType) { … }
llvm::Constant *ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) { … }
llvm::Constant *
ConstantEmitter::emitAbstract(const Expr *E, QualType destType) { … }
llvm::Constant *
ConstantEmitter::emitAbstract(SourceLocation loc, const APValue &value,
QualType destType,
bool EnablePtrAuthFunctionTypeDiscrimination) { … }
llvm::Constant *ConstantEmitter::tryEmitForInitializer(const VarDecl &D) { … }
llvm::Constant *ConstantEmitter::tryEmitForInitializer(const Expr *E,
LangAS destAddrSpace,
QualType destType) { … }
llvm::Constant *ConstantEmitter::emitForInitializer(const APValue &value,
LangAS destAddrSpace,
QualType destType) { … }
llvm::GlobalValue *ConstantEmitter::getCurrentAddrPrivate() { … }
void ConstantEmitter::registerCurrentAddrPrivate(llvm::Constant *signal,
llvm::GlobalValue *placeholder) { … }
namespace {
struct ReplacePlaceholders { … };
}
void ConstantEmitter::finalize(llvm::GlobalVariable *global) { … }
ConstantEmitter::~ConstantEmitter() { … }
static QualType getNonMemoryType(CodeGenModule &CGM, QualType type) { … }
llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) { … }
llvm::Constant *
ConstantEmitter::tryEmitAbstractForMemory(const Expr *E, QualType destType) { … }
llvm::Constant *
ConstantEmitter::tryEmitAbstractForMemory(const APValue &value,
QualType destType) { … }
llvm::Constant *ConstantEmitter::tryEmitPrivateForMemory(const Expr *E,
QualType destType) { … }
llvm::Constant *ConstantEmitter::tryEmitPrivateForMemory(const APValue &value,
QualType destType) { … }
llvm::Constant *
ConstantEmitter::tryEmitConstantSignedPointer(llvm::Constant *UnsignedPointer,
PointerAuthQualifier Schema) { … }
llvm::Constant *ConstantEmitter::emitForMemory(CodeGenModule &CGM,
llvm::Constant *C,
QualType destType) { … }
llvm::Constant *ConstantEmitter::tryEmitPrivate(const Expr *E,
QualType destType) { … }
llvm::Constant *CodeGenModule::getNullPointer(llvm::PointerType *T, QualType QT) { … }
namespace {
struct ConstantLValue { … };
class ConstantLValueEmitter : public ConstStmtVisitor<ConstantLValueEmitter,
ConstantLValue> { … };
}
llvm::Constant *ConstantLValueEmitter::tryEmit() { … }
llvm::Constant *
ConstantLValueEmitter::tryEmitAbsolute(llvm::Type *destTy) { … }
ConstantLValue
ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) { … }
ConstantLValue
ConstantLValueEmitter::VisitConstantExpr(const ConstantExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitStringLiteral(const StringLiteral *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitObjCEncodeExpr(const ObjCEncodeExpr *E) { … }
static ConstantLValue emitConstantObjCStringLiteral(const StringLiteral *S,
QualType T,
CodeGenModule &CGM) { … }
ConstantLValue
ConstantLValueEmitter::VisitObjCStringLiteral(const ObjCStringLiteral *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitPredefinedExpr(const PredefinedExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitAddrLabelExpr(const AddrLabelExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitCallExpr(const CallExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::emitPointerAuthSignConstant(const CallExpr *E) { … }
llvm::Constant *ConstantLValueEmitter::emitPointerAuthPointer(const Expr *E) { … }
unsigned ConstantLValueEmitter::emitPointerAuthKey(const Expr *E) { … }
std::pair<llvm::Constant *, llvm::ConstantInt *>
ConstantLValueEmitter::emitPointerAuthDiscriminator(const Expr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitBlockExpr(const BlockExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitCXXTypeidExpr(const CXXTypeidExpr *E) { … }
ConstantLValue
ConstantLValueEmitter::VisitMaterializeTemporaryExpr(
const MaterializeTemporaryExpr *E) { … }
llvm::Constant *
ConstantEmitter::tryEmitPrivate(const APValue &Value, QualType DestType,
bool EnablePtrAuthFunctionTypeDiscrimination) { … }
llvm::GlobalVariable *CodeGenModule::getAddrOfConstantCompoundLiteralIfEmitted(
const CompoundLiteralExpr *E) { … }
void CodeGenModule::setAddrOfConstantCompoundLiteral(
const CompoundLiteralExpr *CLE, llvm::GlobalVariable *GV) { … }
ConstantAddress
CodeGenModule::GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E) { … }
llvm::Constant *
CodeGenModule::getMemberPointerConstant(const UnaryOperator *uo) { … }
static llvm::Constant *EmitNullConstantForBase(CodeGenModule &CGM,
llvm::Type *baseType,
const CXXRecordDecl *base);
static llvm::Constant *EmitNullConstant(CodeGenModule &CGM,
const RecordDecl *record,
bool asCompleteObject) { … }
static llvm::Constant *EmitNullConstantForBase(CodeGenModule &CGM,
llvm::Type *baseType,
const CXXRecordDecl *base) { … }
llvm::Constant *ConstantEmitter::emitNullForMemory(CodeGenModule &CGM,
QualType T) { … }
llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) { … }
llvm::Constant *
CodeGenModule::EmitNullConstantForBase(const CXXRecordDecl *Record) { … }