#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CGRecordLayout.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ParentMapContext.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/APFixedPoint.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/FixedPointBuilder.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GEPNoWrapFlags.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsPowerPC.h"
#include "llvm/IR/MatrixBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/TypeSize.h"
#include <cstdarg>
#include <optional>
usingnamespaceclang;
usingnamespaceCodeGen;
Value;
namespace llvm {
extern cl::opt<bool> EnableSingleByteCoverage;
}
namespace {
bool mayHaveIntegerOverflow(llvm::ConstantInt *LHS, llvm::ConstantInt *RHS,
BinaryOperator::Opcode Opcode, bool Signed,
llvm::APInt &Result) { … }
struct BinOpInfo { … };
static bool MustVisitNullValue(const Expr *E) { … }
static std::optional<QualType> getUnwidenedIntegerType(const ASTContext &Ctx,
const Expr *E) { … }
static bool IsWidenedIntegerOp(const ASTContext &Ctx, const Expr *E) { … }
static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) { … }
class ScalarExprEmitter
: public StmtVisitor<ScalarExprEmitter, Value*> { … } … };
}
Value *ScalarExprEmitter::EmitConversionToBool(Value *Src, QualType SrcType) { … }
void ScalarExprEmitter::EmitFloatConversionCheck(
Value *OrigSrc, QualType OrigSrcType, Value *Src, QualType SrcType,
QualType DstType, llvm::Type *DstTy, SourceLocation Loc) { … }
static std::pair<ScalarExprEmitter::ImplicitConversionCheckKind,
std::pair<llvm::Value *, SanitizerMask>>
EmitIntegerTruncationCheckHelper(Value *Src, QualType SrcType, Value *Dst,
QualType DstType, CGBuilderTy &Builder) { … }
static bool PromotionIsPotentiallyEligibleForImplicitIntegerConversionCheck(
QualType SrcType, QualType DstType) { … }
void ScalarExprEmitter::EmitIntegerTruncationCheck(Value *Src, QualType SrcType,
Value *Dst, QualType DstType,
SourceLocation Loc) { … }
static llvm::Value *EmitIsNegativeTestHelper(Value *V, QualType VType,
const char *Name,
CGBuilderTy &Builder) { … }
static std::pair<ScalarExprEmitter::ImplicitConversionCheckKind,
std::pair<llvm::Value *, SanitizerMask>>
EmitIntegerSignChangeCheckHelper(Value *Src, QualType SrcType, Value *Dst,
QualType DstType, CGBuilderTy &Builder) { … }
void ScalarExprEmitter::EmitIntegerSignChangeCheck(Value *Src, QualType SrcType,
Value *Dst, QualType DstType,
SourceLocation Loc) { … }
static std::pair<ScalarExprEmitter::ImplicitConversionCheckKind,
std::pair<llvm::Value *, SanitizerMask>>
EmitBitfieldTruncationCheckHelper(Value *Src, QualType SrcType, Value *Dst,
QualType DstType, CGBuilderTy &Builder) { … }
static std::pair<ScalarExprEmitter::ImplicitConversionCheckKind,
std::pair<llvm::Value *, SanitizerMask>>
EmitBitfieldSignChangeCheckHelper(Value *Src, QualType SrcType, Value *Dst,
QualType DstType, CGBuilderTy &Builder) { … }
void CodeGenFunction::EmitBitfieldConversionCheck(Value *Src, QualType SrcType,
Value *Dst, QualType DstType,
const CGBitFieldInfo &Info,
SourceLocation Loc) { … }
Value *ScalarExprEmitter::EmitScalarCast(Value *Src, QualType SrcType,
QualType DstType, llvm::Type *SrcTy,
llvm::Type *DstTy,
ScalarConversionOpts Opts) { … }
Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
QualType DstType,
SourceLocation Loc,
ScalarConversionOpts Opts) { … }
Value *ScalarExprEmitter::EmitFixedPointConversion(Value *Src, QualType SrcTy,
QualType DstTy,
SourceLocation Loc) { … }
Value *ScalarExprEmitter::EmitComplexToScalarConversion(
CodeGenFunction::ComplexPairTy Src, QualType SrcTy, QualType DstTy,
SourceLocation Loc) { … }
Value *ScalarExprEmitter::EmitNullValue(QualType Ty) { … }
void ScalarExprEmitter::EmitBinOpCheck(
ArrayRef<std::pair<Value *, SanitizerMask>> Checks, const BinOpInfo &Info) { … }
Value *ScalarExprEmitter::VisitExpr(Expr *E) { … }
Value *
ScalarExprEmitter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) { … }
Value *ScalarExprEmitter::VisitEmbedExpr(EmbedExpr *E) { … }
Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { … }
Value *ScalarExprEmitter::VisitConvertVectorExpr(ConvertVectorExpr *E) { … }
Value *ScalarExprEmitter::VisitMemberExpr(MemberExpr *E) { … }
Value *ScalarExprEmitter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { … }
Value *ScalarExprEmitter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) { … }
static int getMaskElt(llvm::ShuffleVectorInst *SVI, unsigned Idx,
unsigned Off) { … }
static int getAsInt32(llvm::ConstantInt *C, llvm::Type *I32Ty) { … }
Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { … }
bool CodeGenFunction::ShouldNullCheckClassCastValue(const CastExpr *CE) { … }
Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { … }
Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) { … }
Value *ScalarExprEmitter::VisitExprWithCleanups(ExprWithCleanups *E) { … }
static BinOpInfo createBinOpInfoFromIncDec(const UnaryOperator *E,
llvm::Value *InVal, bool IsInc,
FPOptions FPFeatures) { … }
llvm::Value *ScalarExprEmitter::EmitIncDecConsiderOverflowBehavior(
const UnaryOperator *E, llvm::Value *InVal, bool IsInc) { … }
static bool matchesPostDecrInWhile(const UnaryOperator *UO, bool isInc,
bool isPre, ASTContext &Ctx) { … }
namespace {
class OMPLastprivateConditionalUpdateRAII { … };
}
llvm::Value *
ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
bool isInc, bool isPre) { … }
Value *ScalarExprEmitter::VisitUnaryPlus(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::VisitPlus(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::VisitUnaryMinus(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::VisitMinus(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::VisitUnaryNot(const UnaryOperator *E) { … }
Value *ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *E) { … }
Value *ScalarExprEmitter::VisitOffsetOfExpr(OffsetOfExpr *E) { … }
Value *
ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
const UnaryExprOrTypeTraitExpr *E) { … }
Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::VisitReal(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::VisitImag(const UnaryOperator *E,
QualType PromotionType) { … }
Value *ScalarExprEmitter::EmitPromotedValue(Value *result,
QualType PromotionType) { … }
Value *ScalarExprEmitter::EmitUnPromotedValue(Value *result,
QualType ExprType) { … }
Value *ScalarExprEmitter::EmitPromoted(const Expr *E, QualType PromotionType) { … }
BinOpInfo ScalarExprEmitter::EmitBinOps(const BinaryOperator *E,
QualType PromotionType) { … }
LValue ScalarExprEmitter::EmitCompoundAssignLValue(
const CompoundAssignOperator *E,
Value *(ScalarExprEmitter::*Func)(const BinOpInfo &),
Value *&Result) { … }
Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E,
Value *(ScalarExprEmitter::*Func)(const BinOpInfo &)) { … }
void ScalarExprEmitter::EmitUndefinedBehaviorIntegerDivAndRemCheck(
const BinOpInfo &Ops, llvm::Value *Zero, bool isDiv) { … }
Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) { … }
Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) { … }
Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) { … }
static Value *emitPointerArithmetic(CodeGenFunction &CGF,
const BinOpInfo &op,
bool isSubtraction) { … }
static Value* buildFMulAdd(llvm::Instruction *MulOp, Value *Addend,
const CodeGenFunction &CGF, CGBuilderTy &Builder,
bool negMul, bool negAdd) { … }
static Value* tryEmitFMulAdd(const BinOpInfo &op,
const CodeGenFunction &CGF, CGBuilderTy &Builder,
bool isSub=false) { … }
Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &op) { … }
Value *ScalarExprEmitter::EmitFixedPointBinOp(const BinOpInfo &op) { … }
Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) { … }
Value *ScalarExprEmitter::GetMaximumShiftAmount(Value *LHS, Value *RHS,
bool RHSIsSigned) { … }
Value *ScalarExprEmitter::ConstrainShiftValue(Value *LHS, Value *RHS,
const Twine &Name) { … }
Value *ScalarExprEmitter::EmitShl(const BinOpInfo &Ops) { … }
Value *ScalarExprEmitter::EmitShr(const BinOpInfo &Ops) { … }
enum IntrinsicType { … };
static llvm::Intrinsic::ID GetIntrinsic(IntrinsicType IT,
BuiltinType::Kind ElemKind) { … }
Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,
llvm::CmpInst::Predicate UICmpOpc,
llvm::CmpInst::Predicate SICmpOpc,
llvm::CmpInst::Predicate FCmpOpc,
bool IsSignaling) { … }
llvm::Value *CodeGenFunction::EmitWithOriginalRHSBitfieldAssignment(
const BinaryOperator *E, Value **Previous, QualType *SrcType) { … }
Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) { … }
Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { … }
Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { … }
Value *ScalarExprEmitter::VisitBinComma(const BinaryOperator *E) { … }
static bool isCheapEnoughToEvaluateUnconditionally(const Expr *E,
CodeGenFunction &CGF) { … }
Value *ScalarExprEmitter::
VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) { … }
Value *ScalarExprEmitter::VisitChooseExpr(ChooseExpr *E) { … }
Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) { … }
Value *ScalarExprEmitter::VisitBlockExpr(const BlockExpr *block) { … }
static Value *ConvertVec3AndVec4(CGBuilderTy &Builder, CodeGenFunction &CGF,
Value *Src, unsigned NumElementsDst) { … }
static Value *createCastsForTypeOfSameSize(CGBuilderTy &Builder,
const llvm::DataLayout &DL,
Value *Src, llvm::Type *DstTy,
StringRef Name = "") { … }
Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) { … }
Value *ScalarExprEmitter::VisitAtomicExpr(AtomicExpr *E) { … }
Value *CodeGenFunction::EmitScalarExpr(const Expr *E, bool IgnoreResultAssign) { … }
Value *CodeGenFunction::EmitScalarConversion(Value *Src, QualType SrcTy,
QualType DstTy,
SourceLocation Loc) { … }
Value *CodeGenFunction::EmitComplexToScalarConversion(ComplexPairTy Src,
QualType SrcTy,
QualType DstTy,
SourceLocation Loc) { … }
Value *
CodeGenFunction::EmitPromotedScalarExpr(const Expr *E,
QualType PromotionType) { … }
llvm::Value *CodeGenFunction::
EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
bool isInc, bool isPre) { … }
LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) { … }
LValue CodeGenFunction::EmitCompoundAssignmentLValue(
const CompoundAssignOperator *E) { … }
struct GEPOffsetAndOverflow { … };
static GEPOffsetAndOverflow EmitGEPOffsetInBytes(Value *BasePtr, Value *GEPVal,
llvm::LLVMContext &VMContext,
CodeGenModule &CGM,
CGBuilderTy &Builder) { … }
Value *
CodeGenFunction::EmitCheckedInBoundsGEP(llvm::Type *ElemTy, Value *Ptr,
ArrayRef<Value *> IdxList,
bool SignedIndices, bool IsSubtraction,
SourceLocation Loc, const Twine &Name) { … }
Address CodeGenFunction::EmitCheckedInBoundsGEP(
Address Addr, ArrayRef<Value *> IdxList, llvm::Type *elementType,
bool SignedIndices, bool IsSubtraction, SourceLocation Loc, CharUnits Align,
const Twine &Name) { … }