clang
15.0.0git
|
#include "Interp/Context.h"
#include "Interp/Frame.h"
#include "Interp/State.h"
#include "clang/AST/APValue.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/CurrentSourceLocExprScope.h"
#include "clang/AST/Expr.h"
#include "clang/AST/OSLog.h"
#include "clang/AST/OptionalDiagnostic.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/APFixedPoint.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <functional>
#include "clang/AST/TypeNodes.inc"
#include "clang/AST/BuiltinTypes.def"
#include "clang/Basic/OpenCLImageTypes.def"
#include "clang/Basic/OpenCLExtensionTypes.def"
#include "clang/Basic/AArch64SVEACLETypes.def"
#include "clang/Basic/PPCTypes.def"
#include "clang/Basic/RISCVVTypes.def"
#include "clang/AST/StmtNodes.inc"
Go to the source code of this file.
Classes | |
struct | llvm::DenseMapInfo< ObjectUnderConstruction > |
struct | DynamicType |
Namespaces | |
llvm | |
YAML serialization mapping. | |
Macros | |
#define | DEBUG_TYPE "exprconstant" |
#define | TYPE(Class, Base) |
#define | ABSTRACT_TYPE(Class, Base) |
#define | NON_CANONICAL_TYPE(Class, Base) |
#define | DEPENDENT_TYPE(Class, Base) |
#define | NON_CANONICAL_UNLESS_DEPENDENT(Class, Base) |
#define | TYPE(ID, BASE) |
#define | DEPENDENT_TYPE(ID, BASE) case Type::ID: |
#define | NON_CANONICAL_TYPE(ID, BASE) case Type::ID: |
#define | NON_CANONICAL_UNLESS_DEPENDENT_TYPE(ID, BASE) case Type::ID: |
#define | BUILTIN_TYPE(ID, SINGLETON_ID) |
#define | SIGNED_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return GCCTypeClass::Integer; |
#define | FLOATING_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return GCCTypeClass::RealFloat; |
#define | PLACEHOLDER_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: break; |
#define | IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) case BuiltinType::Id: |
#define | EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id: |
#define | SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: |
#define | PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id: |
#define | RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id: |
#define | ABSTRACT_STMT(Node) |
#define | STMT(Node, Base) case Expr::Node##Class: |
#define | EXPR(Node, Base) |
Typedefs | |
using | CheckedTemporaries = llvm::SmallPtrSet< const MaterializeTemporaryExpr *, 8 > |
Materialized temporaries that we've already checked to determine if they're initializsed by a constant expression. More... | |
Enumerations | |
enum | CheckEvaluationResultKind { CheckEvaluationResultKind::ConstantExpression, CheckEvaluationResultKind::FullyInitialized } |
enum | GCCTypeClass { GCCTypeClass::None = -1, GCCTypeClass::Void = 0, GCCTypeClass::Integer = 1, GCCTypeClass::Enum = 3, GCCTypeClass::Bool = 4, GCCTypeClass::Pointer = 5, GCCTypeClass::PointerToDataMember = 7, GCCTypeClass::RealFloat = 8, GCCTypeClass::Complex = 9, GCCTypeClass::PointerToMemberFunction = 12, GCCTypeClass::ClassOrStruct = 12, GCCTypeClass::Union = 13 } |
Values returned by __builtin_classify_type, chosen to match the values produced by GCC's builtin. More... | |
Functions | |
static bool | HandleDestruction (EvalInfo &Info, const Expr *E, const LValue &This, QualType ThisType) |
Perform a destructor or pseudo-destructor call on the given object, which might in general not be a complete object. More... | |
static bool | HandleDestruction (EvalInfo &Info, SourceLocation Loc, APValue::LValueBase LVBase, APValue &Value, QualType T) |
Destroy and end the lifetime of the given complete object. More... | |
static bool | isRead (AccessKinds AK) |
static bool | isModification (AccessKinds AK) |
static bool | isAnyAccess (AccessKinds AK) |
static bool | isFormalAccess (AccessKinds AK) |
Is this an access per the C++ definition? More... | |
static bool | isValidIndeterminateAccess (AccessKinds AK) |
Is this kind of axcess valid on an indeterminate object value? More... | |
static bool | Evaluate (APValue &Result, EvalInfo &Info, const Expr *E) |
static bool | EvaluateInPlace (APValue &Result, EvalInfo &Info, const LValue &This, const Expr *E, bool AllowNonLiteralTypes) |
EvaluateInPlace - Evaluate an expression in-place in an APValue. More... | |
static bool | EvaluateLValue (const Expr *E, LValue &Result, EvalInfo &Info, bool InvalidBaseOK) |
Evaluate an expression as an lvalue. More... | |
static bool | EvaluatePointer (const Expr *E, LValue &Result, EvalInfo &Info, bool InvalidBaseOK=false) |
static bool | EvaluateMemberPointer (const Expr *E, MemberPtr &Result, EvalInfo &Info) |
static bool | EvaluateTemporary (const Expr *E, LValue &Result, EvalInfo &Info) |
Evaluate an expression of record type as a temporary. More... | |
static bool | EvaluateInteger (const Expr *E, APSInt &Result, EvalInfo &Info) |
static bool | EvaluateIntegerOrLValue (const Expr *E, APValue &Result, EvalInfo &Info) |
EvaluateIntegerOrLValue - Evaluate an rvalue integral-typed expression, and produce either the integer value or a pointer. More... | |
static bool | EvaluateFloat (const Expr *E, APFloat &Result, EvalInfo &Info) |
static bool | EvaluateComplex (const Expr *E, ComplexValue &Res, EvalInfo &Info) |
static bool | EvaluateAtomic (const Expr *E, const LValue *This, APValue &Result, EvalInfo &Info) |
static bool | EvaluateAsRValue (EvalInfo &Info, const Expr *E, APValue &Result) |
EvaluateAsRValue - Try to evaluate this expression, performing an implicit lvalue-to-rvalue cast if it is an lvalue. More... | |
static bool | EvaluateBuiltinStrLen (const Expr *E, uint64_t &Result, EvalInfo &Info) |
static bool | EvaluateFixedPointOrInteger (const Expr *E, APFixedPoint &Result, EvalInfo &Info) |
Evaluate an integer or fixed point expression into an APResult. More... | |
static bool | EvaluateFixedPoint (const Expr *E, APFixedPoint &Result, EvalInfo &Info) |
Evaluate only a fixed point expression into an APResult. More... | |
static void | negateAsSigned (APSInt &Int) |
Negate an APSInt in place, converting it to a signed form if necessary, and preserving its value (by extending by up to one bit as needed). More... | |
static bool | EvaluateIgnoredValue (EvalInfo &Info, const Expr *E) |
Evaluate an expression to see if it had side-effects, and discard its result. More... | |
static bool | IsConstantCall (const CallExpr *E) |
Should this call expression be treated as a constant? More... | |
static bool | IsGlobalLValue (APValue::LValueBase B) |
static const ValueDecl * | GetLValueBaseDecl (const LValue &LVal) |
static bool | IsLiteralLValue (const LValue &Value) |
static bool | IsWeakLValue (const LValue &Value) |
static bool | isZeroSized (const LValue &Value) |
static bool | HasSameBase (const LValue &A, const LValue &B) |
static void | NoteLValueLocation (EvalInfo &Info, APValue::LValueBase Base) |
static bool | CheckEvaluationResult (CheckEvaluationResultKind CERK, EvalInfo &Info, SourceLocation DiagLoc, QualType Type, const APValue &Value, ConstantExprKind Kind, SourceLocation SubobjectLoc, CheckedTemporaries &CheckedTemps) |
static bool | CheckLValueConstantExpression (EvalInfo &Info, SourceLocation Loc, QualType Type, const LValue &LVal, ConstantExprKind Kind, CheckedTemporaries &CheckedTemps) |
Check that this reference or pointer core constant expression is a valid value for an address or reference constant expression. More... | |
static bool | CheckMemberPointerConstantExpression (EvalInfo &Info, SourceLocation Loc, QualType Type, const APValue &Value, ConstantExprKind Kind) |
Member pointers are constant expressions unless they point to a non-virtual dllimport member function. More... | |
static bool | CheckLiteralType (EvalInfo &Info, const Expr *E, const LValue *This=nullptr) |
Check that this core constant expression is of literal type, and if not, produce an appropriate diagnostic. More... | |
static bool | CheckConstantExpression (EvalInfo &Info, SourceLocation DiagLoc, QualType Type, const APValue &Value, ConstantExprKind Kind) |
Check that this core constant expression value is a valid value for a constant expression. More... | |
static bool | CheckFullyInitialized (EvalInfo &Info, SourceLocation DiagLoc, QualType Type, const APValue &Value) |
Check that this evaluated value is fully-initialized and can be loaded by an lvalue-to-rvalue conversion. More... | |
static bool | CheckMemoryLeaks (EvalInfo &Info) |
Enforce C++2a [expr.const]/4.17, which disallows new-expressions unless "the allocated storage is deallocated within the evaluation". More... | |
static bool | EvalPointerValueAsBool (const APValue &Value, bool &Result) |
static bool | HandleConversionToBool (const APValue &Val, bool &Result) |
static bool | EvaluateAsBooleanCondition (const Expr *E, bool &Result, EvalInfo &Info) |
template<typename T > | |
static bool | HandleOverflow (EvalInfo &Info, const Expr *E, const T &SrcValue, QualType DestType) |
static bool | HandleFloatToIntCast (EvalInfo &Info, const Expr *E, QualType SrcType, const APFloat &Value, QualType DestType, APSInt &Result) |
static llvm::RoundingMode | getActiveRoundingMode (EvalInfo &Info, const Expr *E) |
Get rounding mode to use in evaluation of the specified expression. More... | |
static bool | checkFloatingPointResult (EvalInfo &Info, const Expr *E, APFloat::opStatus St) |
Check if the given evaluation result is allowed for constant evaluation. More... | |
static bool | HandleFloatToFloatCast (EvalInfo &Info, const Expr *E, QualType SrcType, QualType DestType, APFloat &Result) |
static APSInt | HandleIntToIntCast (EvalInfo &Info, const Expr *E, QualType DestType, QualType SrcType, const APSInt &Value) |
static bool | HandleIntToFloatCast (EvalInfo &Info, const Expr *E, const FPOptions FPO, QualType SrcType, const APSInt &Value, QualType DestType, APFloat &Result) |
static bool | truncateBitfieldValue (EvalInfo &Info, const Expr *E, APValue &Value, const FieldDecl *FD) |
static bool | EvalAndBitcastToAPInt (EvalInfo &Info, const Expr *E, llvm::APInt &Res) |
template<typename Operation > | |
static bool | CheckedIntArithmetic (EvalInfo &Info, const Expr *E, const APSInt &LHS, const APSInt &RHS, unsigned BitWidth, Operation Op, APSInt &Result) |
Perform the given integer operation, which is known to need at most BitWidth bits, and check for overflow in the original type (if that type was not an unsigned type). More... | |
static bool | handleIntIntBinOp (EvalInfo &Info, const Expr *E, const APSInt &LHS, BinaryOperatorKind Opcode, APSInt RHS, APSInt &Result) |
Perform the given binary integer operation. More... | |
static bool | handleFloatFloatBinOp (EvalInfo &Info, const BinaryOperator *E, APFloat &LHS, BinaryOperatorKind Opcode, const APFloat &RHS) |
Perform the given binary floating-point operation, in-place, on LHS. More... | |
static bool | handleLogicalOpForVector (const APInt &LHSValue, BinaryOperatorKind Opcode, const APInt &RHSValue, APInt &Result) |
static bool | handleLogicalOpForVector (const APFloat &LHSValue, BinaryOperatorKind Opcode, const APFloat &RHSValue, APInt &Result) |
static bool | handleLogicalOpForVector (const APValue &LHSValue, BinaryOperatorKind Opcode, const APValue &RHSValue, APInt &Result) |
template<typename APTy > | |
static bool | handleCompareOpForVectorHelper (const APTy &LHSValue, BinaryOperatorKind Opcode, const APTy &RHSValue, APInt &Result) |
static bool | handleCompareOpForVector (const APValue &LHSValue, BinaryOperatorKind Opcode, const APValue &RHSValue, APInt &Result) |
static bool | handleVectorVectorBinOp (EvalInfo &Info, const BinaryOperator *E, BinaryOperatorKind Opcode, APValue &LHSValue, const APValue &RHSValue) |
static bool | CastToDerivedClass (EvalInfo &Info, const Expr *E, LValue &Result, const RecordDecl *TruncatedType, unsigned TruncatedElements) |
Cast an lvalue referring to a base subobject to a derived class, by truncating the lvalue's path to the given length. More... | |
static bool | HandleLValueDirectBase (EvalInfo &Info, const Expr *E, LValue &Obj, const CXXRecordDecl *Derived, const CXXRecordDecl *Base, const ASTRecordLayout *RL=nullptr) |
static bool | HandleLValueBase (EvalInfo &Info, const Expr *E, LValue &Obj, const CXXRecordDecl *DerivedDecl, const CXXBaseSpecifier *Base) |
static bool | HandleLValueBasePath (EvalInfo &Info, const CastExpr *E, QualType Type, LValue &Result) |
static bool | CastToBaseClass (EvalInfo &Info, const Expr *E, LValue &Result, const CXXRecordDecl *DerivedRD, const CXXRecordDecl *BaseRD) |
Cast an lvalue referring to a derived class to a known base subobject. More... | |
static bool | HandleLValueMember (EvalInfo &Info, const Expr *E, LValue &LVal, const FieldDecl *FD, const ASTRecordLayout *RL=nullptr) |
Update LVal to refer to the given field, which must be a member of the type currently described by LVal. More... | |
static bool | HandleLValueIndirectMember (EvalInfo &Info, const Expr *E, LValue &LVal, const IndirectFieldDecl *IFD) |
Update LVal to refer to the given indirect field. More... | |
static bool | HandleSizeof (EvalInfo &Info, SourceLocation Loc, QualType Type, CharUnits &Size) |
Get the size of the given type in char units. More... | |
static bool | HandleLValueArrayAdjustment (EvalInfo &Info, const Expr *E, LValue &LVal, QualType EltTy, APSInt Adjustment) |
Update a pointer value to model pointer arithmetic. More... | |
static bool | HandleLValueArrayAdjustment (EvalInfo &Info, const Expr *E, LValue &LVal, QualType EltTy, int64_t Adjustment) |
static bool | HandleLValueComplexElement (EvalInfo &Info, const Expr *E, LValue &LVal, QualType EltTy, bool Imag) |
Update an lvalue to refer to a component of a complex number. More... | |
static bool | evaluateVarDeclInit (EvalInfo &Info, const Expr *E, const VarDecl *VD, CallStackFrame *Frame, unsigned Version, APValue *&Result) |
Try to evaluate the initializer for a variable declaration. More... | |
static unsigned | getBaseIndex (const CXXRecordDecl *Derived, const CXXRecordDecl *Base) |
Get the base index of the given base class within an APValue representing the given derived class. More... | |
static APSInt | extractStringLiteralCharacter (EvalInfo &Info, const Expr *Lit, uint64_t Index) |
Extract the value of a character from a string literal. More... | |
static void | expandStringLiteral (EvalInfo &Info, const StringLiteral *S, APValue &Result, QualType AllocType=QualType()) |
static void | expandArray (APValue &Array, unsigned Index) |
static bool | isReadByLvalueToRvalueConversion (const CXXRecordDecl *RD) |
Determine whether a type would actually be read by an lvalue-to-rvalue conversion. More... | |
static bool | isReadByLvalueToRvalueConversion (QualType T) |
static bool | diagnoseMutableFields (EvalInfo &Info, const Expr *E, AccessKinds AK, QualType T) |
Diagnose an attempt to read from any unreadable field within the specified type, which might be a class type. More... | |
static bool | lifetimeStartedInEvaluation (EvalInfo &Info, APValue::LValueBase Base, bool MutableSubobject=false) |
static QualType | getSubobjectType (QualType ObjType, QualType SubobjType, bool IsMutable=false) |
template<typename SubobjectHandler > | |
SubobjectHandler::result_type | findSubobject (EvalInfo &Info, const Expr *E, const CompleteObject &Obj, const SubobjectDesignator &Sub, SubobjectHandler &handler) |
Find the designated sub-object of an rvalue. More... | |
static bool | extractSubobject (EvalInfo &Info, const Expr *E, const CompleteObject &Obj, const SubobjectDesignator &Sub, APValue &Result, AccessKinds AK=AK_Read) |
Extract the designated sub-object of an rvalue. More... | |
static bool | modifySubobject (EvalInfo &Info, const Expr *E, const CompleteObject &Obj, const SubobjectDesignator &Sub, APValue &NewVal) |
Update the designated sub-object of an rvalue to the given value. More... | |
static unsigned | FindDesignatorMismatch (QualType ObjType, const SubobjectDesignator &A, const SubobjectDesignator &B, bool &WasArrayIndex) |
Find the position where two subobject designators diverge, or equivalently the length of the common initial subsequence. More... | |
static bool | AreElementsOfSameArray (QualType ObjType, const SubobjectDesignator &A, const SubobjectDesignator &B) |
Determine whether the given subobject designators refer to elements of the same array object. More... | |
static CompleteObject | findCompleteObject (EvalInfo &Info, const Expr *E, AccessKinds AK, const LValue &LVal, QualType LValType) |
Find the complete object to which an LValue refers. More... | |
static bool | handleLValueToRValueConversion (EvalInfo &Info, const Expr *Conv, QualType Type, const LValue &LVal, APValue &RVal, bool WantObjectRepresentation=false) |
Perform an lvalue-to-rvalue conversion on the given glvalue. More... | |
static bool | handleAssignment (EvalInfo &Info, const Expr *E, const LValue &LVal, QualType LValType, APValue &Val) |
Perform an assignment of Val to LVal. Takes ownership of Val. More... | |
static bool | handleCompoundAssignment (EvalInfo &Info, const CompoundAssignOperator *E, const LValue &LVal, QualType LValType, QualType PromotedLValType, BinaryOperatorKind Opcode, const APValue &RVal) |
Perform a compound assignment of LVal <op>= RVal. More... | |
static bool | handleIncDec (EvalInfo &Info, const Expr *E, const LValue &LVal, QualType LValType, bool IsIncrement, APValue *Old) |
Perform an increment or decrement on LVal. More... | |
static bool | EvaluateObjectArgument (EvalInfo &Info, const Expr *Object, LValue &This) |
Build an lvalue for the object argument of a member function call. More... | |
static const ValueDecl * | HandleMemberPointerAccess (EvalInfo &Info, QualType LVType, LValue &LV, const Expr *RHS, bool IncludeMember=true) |
HandleMemberPointerAccess - Evaluate a member access operation and build an lvalue referring to the result. More... | |
static const ValueDecl * | HandleMemberPointerAccess (EvalInfo &Info, const BinaryOperator *BO, LValue &LV, bool IncludeMember=true) |
static bool | HandleBaseToDerivedCast (EvalInfo &Info, const CastExpr *E, LValue &Result) |
HandleBaseToDerivedCast - Apply the given base-to-derived cast operation on the provided lvalue, which currently refers to the base object. More... | |
static bool | getDefaultInitValue (QualType T, APValue &Result) |
Get the value to use for a default-initialized object of type T. More... | |
static bool | EvaluateVarDecl (EvalInfo &Info, const VarDecl *VD) |
static bool | EvaluateDecl (EvalInfo &Info, const Decl *D) |
static bool | EvaluateDependentExpr (const Expr *E, EvalInfo &Info) |
static bool | EvaluateCond (EvalInfo &Info, const VarDecl *CondDecl, const Expr *Cond, bool &Result) |
Evaluate a condition (either a variable declaration or an expression). More... | |
static EvalStmtResult | EvaluateStmt (StmtResult &Result, EvalInfo &Info, const Stmt *S, const SwitchCase *SC=nullptr) |
static EvalStmtResult | EvaluateLoopBody (StmtResult &Result, EvalInfo &Info, const Stmt *Body, const SwitchCase *Case=nullptr) |
Evaluate the body of a loop, and translate the result as appropriate. More... | |
static EvalStmtResult | EvaluateSwitch (StmtResult &Result, EvalInfo &Info, const SwitchStmt *SS) |
Evaluate a switch statement. More... | |
static bool | CheckLocalVariableDeclaration (EvalInfo &Info, const VarDecl *VD) |
static bool | CheckTrivialDefaultConstructor (EvalInfo &Info, SourceLocation Loc, const CXXConstructorDecl *CD, bool IsValueInitialization) |
CheckTrivialDefaultConstructor - Check whether a constructor is a trivial default constructor. More... | |
static bool | CheckConstexprFunction (EvalInfo &Info, SourceLocation CallLoc, const FunctionDecl *Declaration, const FunctionDecl *Definition, const Stmt *Body) |
CheckConstexprFunction - Check that a function can be called in a constant expression. More... | |
static bool | checkDynamicType (EvalInfo &Info, const Expr *E, const LValue &This, AccessKinds AK, bool Polymorphic) |
Check that we can access the notional vptr of an object / determine its dynamic type. More... | |
static bool | checkNonVirtualMemberCallThisPointer (EvalInfo &Info, const Expr *E, const LValue &This, const CXXMethodDecl *NamedMember) |
Check that the pointee of the 'this' pointer in a member function call is either within its lifetime or in its period of construction or destruction. More... | |
static const CXXRecordDecl * | getBaseClassType (SubobjectDesignator &Designator, unsigned PathLength) |
static Optional< DynamicType > | ComputeDynamicType (EvalInfo &Info, const Expr *E, LValue &This, AccessKinds AK) |
Determine the dynamic type of an object. More... | |
static const CXXMethodDecl * | HandleVirtualDispatch (EvalInfo &Info, const Expr *E, LValue &This, const CXXMethodDecl *Found, llvm::SmallVectorImpl< QualType > &CovariantAdjustmentPath) |
Perform virtual dispatch. More... | |
static bool | HandleCovariantReturnAdjustment (EvalInfo &Info, const Expr *E, APValue &Result, ArrayRef< QualType > Path) |
Perform the adjustment from a value returned by a virtual function to a value of the statically expected type, which may be a pointer or reference to a base class of the returned type. More... | |
static bool | isBaseClassPublic (const CXXRecordDecl *Derived, const CXXRecordDecl *Base) |
Determine whether Base , which is known to be a direct base class of Derived , is a public base class. More... | |
static bool | HandleDynamicCast (EvalInfo &Info, const ExplicitCastExpr *E, LValue &Ptr) |
Apply the given dynamic cast operation on the provided lvalue. More... | |
static bool | HandleUnionActiveMemberChange (EvalInfo &Info, const Expr *LHSExpr, const LValue &LHS) |
Handle a builtin simple-assignment or a call to a trivial assignment operator whose left-hand side might involve a union member access. More... | |
static bool | EvaluateCallArg (const ParmVarDecl *PVD, const Expr *Arg, CallRef Call, EvalInfo &Info, bool NonNull=false) |
static bool | EvaluateArgs (ArrayRef< const Expr * > Args, CallRef Call, EvalInfo &Info, const FunctionDecl *Callee, bool RightToLeft=false) |
Evaluate the arguments to a function call. More... | |
static bool | handleTrivialCopy (EvalInfo &Info, const ParmVarDecl *Param, const Expr *E, APValue &Result, bool CopyObjectRepresentation) |
Perform a trivial copy from Param, which is the parameter of a copy or move constructor or assignment operator. More... | |
static bool | HandleFunctionCall (SourceLocation CallLoc, const FunctionDecl *Callee, const LValue *This, ArrayRef< const Expr * > Args, CallRef Call, const Stmt *Body, EvalInfo &Info, APValue &Result, const LValue *ResultSlot) |
Evaluate a function call. More... | |
static bool | HandleConstructorCall (const Expr *E, const LValue &This, CallRef Call, const CXXConstructorDecl *Definition, EvalInfo &Info, APValue &Result) |
Evaluate a constructor call. More... | |
static bool | HandleConstructorCall (const Expr *E, const LValue &This, ArrayRef< const Expr * > Args, const CXXConstructorDecl *Definition, EvalInfo &Info, APValue &Result) |
static bool | HandleDestructionImpl (EvalInfo &Info, SourceLocation CallLoc, const LValue &This, APValue &Value, QualType T) |
static bool | HandleOperatorNewCall (EvalInfo &Info, const CallExpr *E, LValue &Result) |
Perform a call to 'perator new' or to ‘__builtin_operator_new’. More... | |
static bool | hasVirtualDestructor (QualType T) |
static const FunctionDecl * | getVirtualOperatorDelete (QualType T) |
static Optional< DynAlloc * > | CheckDeleteKind (EvalInfo &Info, const Expr *E, const LValue &Pointer, DynAlloc::Kind DeallocKind) |
Check that the given object is a suitable pointer to a heap allocation that still exists and is of the right kind for the purpose of a deletion. More... | |
bool | HandleOperatorDeleteCall (EvalInfo &Info, const CallExpr *E) |
static bool | getBytesReturnedByAllocSizeCall (const ASTContext &Ctx, const CallExpr *Call, llvm::APInt &Result) |
Attempts to compute the number of bytes available at the pointer returned by a function with the alloc_size attribute. More... | |
static bool | getBytesReturnedByAllocSizeCall (const ASTContext &Ctx, const LValue &LVal, llvm::APInt &Result) |
Convenience function. More... | |
static bool | evaluateLValueAsAllocSize (EvalInfo &Info, APValue::LValueBase Base, LValue &Result) |
Attempts to evaluate the given LValueBase as the result of a call to a function with the alloc_size attribute. More... | |
static bool | IsDeclSourceLocationCurrent (const FunctionDecl *FD) |
static CharUnits | GetAlignOfType (EvalInfo &Info, QualType T, UnaryExprOrTypeTrait ExprKind) |
static CharUnits | GetAlignOfExpr (EvalInfo &Info, const Expr *E, UnaryExprOrTypeTrait ExprKind) |
static CharUnits | getBaseAlignment (EvalInfo &Info, const LValue &Value) |
static bool | getAlignmentArgument (const Expr *E, QualType ForType, EvalInfo &Info, APSInt &Alignment) |
Evaluate the value of the alignment argument to __builtin_align_{up,down}, __builtin_is_aligned and __builtin_assume_aligned. More... | |
static bool | isOneByteCharacterType (QualType T) |
static bool | EvaluateArrayNewInitList (EvalInfo &Info, LValue &This, APValue &Result, const InitListExpr *ILE, QualType AllocType) |
static bool | EvaluateArrayNewConstructExpr (EvalInfo &Info, LValue &This, APValue &Result, const CXXConstructExpr *CCE, QualType AllocType) |
static bool | HandleClassZeroInitialization (EvalInfo &Info, const Expr *E, const RecordDecl *RD, const LValue &This, APValue &Result) |
Perform zero-initialization on an object of non-union class type. More... | |
static bool | EvaluateRecord (const Expr *E, const LValue &This, APValue &Result, EvalInfo &Info) |
static bool | EvaluateVector (const Expr *E, APValue &Result, EvalInfo &Info) |
static llvm::Optional< APValue > | handleVectorUnaryOperator (ASTContext &Ctx, QualType ResultTy, UnaryOperatorKind Op, APValue Elt) |
static bool | EvaluateArray (const Expr *E, const LValue &This, APValue &Result, EvalInfo &Info) |
static bool | MaybeElementDependentArrayFiller (const Expr *FillerExpr) |
static GCCTypeClass | EvaluateBuiltinClassifyType (QualType T, const LangOptions &LangOpts) |
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC. More... | |
static GCCTypeClass | EvaluateBuiltinClassifyType (const CallExpr *E, const LangOptions &LangOpts) |
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC. More... | |
static bool | EvaluateBuiltinConstantPForLValue (const APValue &LV) |
EvaluateBuiltinConstantPForLValue - Determine the result of __builtin_constant_p when applied to the given pointer. More... | |
static bool | EvaluateBuiltinConstantP (EvalInfo &Info, const Expr *Arg) |
EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to GCC as we can manage. More... | |
static QualType | getObjectType (APValue::LValueBase B) |
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size. More... | |
static const Expr * | ignorePointerCastsAndParens (const Expr *E) |
A more selective version of E->IgnoreParenCasts for tryEvaluateBuiltinObjectSize. More... | |
static bool | isDesignatorAtObjectEnd (const ASTContext &Ctx, const LValue &LVal) |
Checks to see if the given LValue's Designator is at the end of the LValue's record layout. More... | |
static bool | refersToCompleteObject (const LValue &LVal) |
Tests to see if the LValue has a user-specified designator (that isn't necessarily valid). More... | |
static bool | isUserWritingOffTheEnd (const ASTContext &Ctx, const LValue &LVal) |
Attempts to detect a user writing into a piece of memory that's impossible to figure out the size of by just using types. More... | |
static bool | convertUnsignedAPIntToCharUnits (const llvm::APInt &Int, CharUnits &Result) |
Converts the given APInt to CharUnits, assuming the APInt is unsigned. More... | |
static bool | determineEndOffset (EvalInfo &Info, SourceLocation ExprLoc, unsigned Type, const LValue &LVal, CharUnits &EndOffset) |
Helper for tryEvaluateBuiltinObjectSize – Given an LValue, this will determine how many bytes exist from the beginning of the object to either the end of the current subobject, or the end of the object itself, depending on what the LValue looks like + the value of Type. More... | |
static bool | tryEvaluateBuiltinObjectSize (const Expr *E, unsigned Type, EvalInfo &Info, uint64_t &Size) |
Tries to evaluate the __builtin_object_size for E . More... | |
static bool | getBuiltinAlignArguments (const CallExpr *E, EvalInfo &Info, APValue &Val, APSInt &Alignment) |
static bool | isOnePastTheEndOfCompleteObject (const ASTContext &Ctx, const LValue &LV) |
Determine whether this is a pointer past the end of the complete object referred to by the lvalue. More... | |
static void | addOrSubLValueAsInteger (APValue &LVal, const APSInt &Index, bool IsSub) |
template<class SuccessCB , class AfterCB > | |
static bool | EvaluateComparisonBinaryOperator (EvalInfo &Info, const BinaryOperator *E, SuccessCB &&Success, AfterCB &&DoAfter) |
static bool | TryEvaluateBuiltinNaN (const ASTContext &Context, QualType ResultTy, const Expr *Arg, bool SNaN, llvm::APFloat &Result) |
static bool | EvaluateVoid (const Expr *E, EvalInfo &Info) |
static bool | FastEvaluateAsRValue (const Expr *Exp, Expr::EvalResult &Result, const ASTContext &Ctx, bool &IsConst) |
static bool | hasUnacceptableSideEffect (Expr::EvalStatus &Result, Expr::SideEffectsKind SEK) |
static bool | EvaluateAsRValue (const Expr *E, Expr::EvalResult &Result, const ASTContext &Ctx, EvalInfo &Info) |
static bool | EvaluateAsInt (const Expr *E, Expr::EvalResult &ExprResult, const ASTContext &Ctx, Expr::SideEffectsKind AllowSideEffects, EvalInfo &Info) |
static bool | EvaluateAsFixedPoint (const Expr *E, Expr::EvalResult &ExprResult, const ASTContext &Ctx, Expr::SideEffectsKind AllowSideEffects, EvalInfo &Info) |
static bool | EvaluateDestruction (const ASTContext &Ctx, APValue::LValueBase Base, APValue DestroyedValue, QualType Type, SourceLocation Loc, Expr::EvalStatus &EStatus, bool IsConstantDestruction) |
static ICEDiag | NoDiag () |
static ICEDiag | Worst (ICEDiag A, ICEDiag B) |
static ICEDiag | CheckEvalInICE (const Expr *E, const ASTContext &Ctx) |
static ICEDiag | CheckICE (const Expr *E, const ASTContext &Ctx) |
static bool | EvaluateCPlusPlus11IntegralConstantExpr (const ASTContext &Ctx, const Expr *E, llvm::APSInt *Value, SourceLocation *Loc) |
Evaluate an expression as a C++11 integral constant expression. More... | |
#define ABSTRACT_STMT | ( | Node | ) |
#define ABSTRACT_TYPE | ( | Class, | |
Base | |||
) |
#define BUILTIN_TYPE | ( | ID, | |
SINGLETON_ID | |||
) |
#define DEBUG_TYPE "exprconstant" |
Definition at line 63 of file ExprConstant.cpp.
#define DEPENDENT_TYPE | ( | Class, | |
Base | |||
) |
#define DEPENDENT_TYPE | ( | ID, | |
BASE | |||
) | case Type::ID: |
#define EXT_OPAQUE_TYPE | ( | ExtType, | |
Id, | |||
Ext | |||
) | case BuiltinType::Id: |
#define FLOATING_TYPE | ( | ID, | |
SINGLETON_ID | |||
) | case BuiltinType::ID: return GCCTypeClass::RealFloat; |
#define IMAGE_TYPE | ( | ImgType, | |
Id, | |||
SingletonId, | |||
Access, | |||
Suffix | |||
) | case BuiltinType::Id: |
#define NON_CANONICAL_TYPE | ( | Class, | |
Base | |||
) |
#define NON_CANONICAL_TYPE | ( | ID, | |
BASE | |||
) | case Type::ID: |
#define NON_CANONICAL_UNLESS_DEPENDENT | ( | Class, | |
Base | |||
) |
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE | ( | ID, | |
BASE | |||
) | case Type::ID: |
#define PLACEHOLDER_TYPE | ( | ID, | |
SINGLETON_ID | |||
) | case BuiltinType::ID: break; |
#define PPC_VECTOR_TYPE | ( | Name, | |
Id, | |||
Size | |||
) | case BuiltinType::Id: |
#define RVV_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | case BuiltinType::Id: |
#define SIGNED_TYPE | ( | ID, | |
SINGLETON_ID | |||
) | case BuiltinType::ID: return GCCTypeClass::Integer; |
#define STMT | ( | Node, | |
Base | |||
) | case Expr::Node##Class: |
#define SVE_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | case BuiltinType::Id: |
#define TYPE | ( | Class, | |
Base | |||
) |
#define TYPE | ( | ID, | |
BASE | |||
) |
using CheckedTemporaries = llvm::SmallPtrSet<const MaterializeTemporaryExpr *, 8> |
Materialized temporaries that we've already checked to determine if they're initializsed by a constant expression.
Definition at line 2113 of file ExprConstant.cpp.
|
strong |
Enumerator | |
---|---|
ConstantExpression | |
FullyInitialized |
Definition at line 2105 of file ExprConstant.cpp.
|
strong |
Values returned by __builtin_classify_type, chosen to match the values produced by GCC's builtin.
Enumerator | |
---|---|
None | |
Void | |
Integer | |
Enum | |
Bool | |
Pointer | |
PointerToDataMember | |
RealFloat | |
Complex | |
PointerToMemberFunction | |
ClassOrStruct | |
Union |
Definition at line 11172 of file ExprConstant.cpp.
Definition at line 12574 of file ExprConstant.cpp.
|
static |
Determine whether the given subobject designators refer to elements of the same array object.
Definition at line 3940 of file ExprConstant.cpp.
References FindDesignatorMismatch().
|
static |
Cast an lvalue referring to a derived class to a known base subobject.
Definition at line 3122 of file ExprConstant.cpp.
Referenced by HandleCovariantReturnAdjustment().
|
static |
Cast an lvalue referring to a base subobject to a derived class, by truncating the lvalue's path to the given length.
Definition at line 3040 of file ExprConstant.cpp.
References clang::CSK_Derived, clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTRecordLayout::getVBaseClassOffset(), and clang::Decl::isInvalidDecl().
Referenced by HandleBaseToDerivedCast(), HandleDynamicCast(), HandleLValueBase(), and HandleMemberPointerAccess().
|
static |
Check that this core constant expression value is a valid value for a constant expression.
If not, report an appropriate diagnostic. Does not check that the expression is of literal type.
Definition at line 2432 of file ExprConstant.cpp.
References CheckEvaluationResult(), ConstantExpression, and clang::Type::isVoidType().
Referenced by clang::Expr::EvaluateAsInitializer(), and EvaluateAsRValue().
|
static |
CheckConstexprFunction - Check that a function can be called in a constant expression.
Definition at line 5520 of file ExprConstant.cpp.
References bool, clang::Decl::getLocation(), and clang::FunctionDecl::isConstexpr().
Referenced by HandleDestructionImpl().
|
static |
Check that the given object is a suitable pointer to a heap allocation that still exists and is of the right kind for the purpose of a deletion.
On success, returns the heap allocation to deallocate. On failure, produces a diagnostic and returns None.
Definition at line 6728 of file ExprConstant.cpp.
References NoteLValueLocation().
Referenced by HandleOperatorDeleteCall().
|
static |
Check that we can access the notional vptr of an object / determine its dynamic type.
Definition at line 5595 of file ExprConstant.cpp.
References findCompleteObject(), findSubobject(), clang::APValue::getAsString(), and clang::interp::This().
Referenced by checkNonVirtualMemberCallThisPointer(), and ComputeDynamicType().
|
static |
Perform the given integer operation, which is known to need at most BitWidth bits, and check for overflow in the original type (if that type was not an unsigned type).
Definition at line 2721 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), clang::Expr::getType(), HandleOverflow(), and clang::threadSafety::sx::toString().
Referenced by handleIntIntBinOp().
|
static |
Definition at line 15312 of file ExprConstant.cpp.
Referenced by CheckICE().
|
static |
Definition at line 2348 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Type::castAsArrayTypeUnsafe(), CheckLValueConstantExpression(), CheckMemberPointerConstantExpression(), ConstantExpression, clang::RecordDecl::fields(), clang::Type::getAs(), clang::ArrayType::getElementType(), and clang::SourceLocation::isValid().
Referenced by CheckConstantExpression(), CheckFullyInitialized(), and CheckLValueConstantExpression().
|
static |
Check if the given evaluation result is allowed for constant evaluation.
Definition at line 2569 of file ExprConstant.cpp.
References clang::FPOptions::getExceptionMode(), clang::Expr::getFPFeaturesInEffect(), and clang::FPOptions::getRoundingMode().
Referenced by handleFloatFloatBinOp(), and HandleFloatToFloatCast().
|
static |
Check that this evaluated value is fully-initialized and can be loaded by an lvalue-to-rvalue conversion.
Definition at line 2447 of file ExprConstant.cpp.
References CheckEvaluationResult(), and FullyInitialized.
|
static |
Definition at line 15325 of file ExprConstant.cpp.
References CheckEvalInICE(), clang::Expr::EvaluateKnownConstInt(), clang::Stmt::getBeginLoc(), clang::CallExpr::getBuiltinCallee(), clang::BinaryConditionalOperator::getCommon(), clang::ConditionalOperator::getCond(), clang::ConditionalOperator::getFalseExpr(), clang::BinaryConditionalOperator::getFalseExpr(), clang::ASTContext::getIntWidth(), clang::UnaryExprOrTypeTraitExpr::getKind(), clang::ASTContext::getLangOpts(), clang::BinaryOperator::getLHS(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Stmt::getStmtClass(), clang::UnaryOperator::getSubExpr(), clang::ConditionalOperator::getTrueExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::UnaryExprOrTypeTraitExpr::getTypeOfArgument(), clang::Expr::IgnoreParenCasts(), clang::Expr::IgnoreParenImpCasts(), clang::Type::isIntegralOrEnumerationType(), clang::Expr::isPRValue(), clang::Type::isReferenceType(), clang::Type::isSignedIntegerOrEnumerationType(), clang::VarDecl::isUsableInConstantExpressions(), clang::Expr::isValueDependent(), clang::Type::isVariableArrayType(), NoDiag(), and Worst().
Referenced by clang::Expr::isCXX98IntegralConstantExpr(), and clang::Expr::isIntegerConstantExpr().
|
static |
Check that this core constant expression is of literal type, and if not, produce an appropriate diagnostic.
Definition at line 2318 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isLiteralType(), clang::Expr::isPRValue(), and clang::interp::This().
Referenced by EvaluateAsRValue(), and EvaluateInPlace().
Definition at line 5040 of file ExprConstant.cpp.
References clang::Decl::getLocation(), clang::VarDecl::getTSCSpec(), clang::VarDecl::isLocalVarDecl(), clang::VarDecl::isStaticLocal(), and clang::TSCS_unspecified.
|
static |
Check that this reference or pointer core constant expression is a valid value for an address or reference constant expression.
Return true if we can fold this expression, whether or not it's a constant expression.
Definition at line 2125 of file ExprConstant.cpp.
References CheckEvaluationResult(), ConstantExpression, clang::Type::isAnyPointerType(), clang::QualType::isDestructedType(), IsGlobalLValue(), clang::Type::isReferenceType(), NoteLValueLocation(), and V.
Referenced by CheckEvaluationResult(), and clang::Expr::EvaluateAsLValue().
|
static |
Member pointers are constant expressions unless they point to a non-virtual dllimport member function.
Definition at line 2298 of file ExprConstant.cpp.
References clang::Member.
Referenced by CheckEvaluationResult().
|
static |
Enforce C++2a [expr.const]/4.17, which disallows new-expressions unless "the allocated storage is deallocated within the evaluation".
Definition at line 2457 of file ExprConstant.cpp.
Referenced by clang::Expr::EvaluateAsInitializer(), and EvaluateAsRValue().
|
static |
Check that the pointee of the 'this' pointer in a member function call is either within its lifetime or in its period of construction or destruction.
Definition at line 5637 of file ExprConstant.cpp.
References clang::AK_Destroy, clang::AK_MemberCall, checkDynamicType(), and clang::interp::This().
|
static |
CheckTrivialDefaultConstructor - Check whether a constructor is a trivial default constructor.
If so, we'll fold it whether or not it's marked as constexpr. If it is marked as constexpr, we will never implicitly define it, so we need special handling.
Definition at line 5495 of file ExprConstant.cpp.
References clang::Decl::getLocation(), clang::FunctionDecl::isConstexpr(), clang::CXXConstructorDecl::isDefaultConstructor(), and clang::FunctionDecl::isTrivial().
|
static |
Determine the dynamic type of an object.
Definition at line 5662 of file ExprConstant.cpp.
References checkDynamicType(), getBaseClassType(), and clang::interp::This().
Referenced by HandleDynamicCast(), and HandleVirtualDispatch().
Converts the given APInt to CharUnits, assuming the APInt is unsigned.
Fails if the conversion would cause loss of precision.
Definition at line 11603 of file ExprConstant.cpp.
References max().
Referenced by determineEndOffset().
|
static |
Helper for tryEvaluateBuiltinObjectSize – Given an LValue, this will determine how many bytes exist from the beginning of the object to either the end of the current subobject, or the end of the object itself, depending on what the LValue looks like + the value of Type.
If this returns false, the value of Result is undefined.
Definition at line 11618 of file ExprConstant.cpp.
References convertUnsignedAPIntToCharUnits(), getBytesReturnedByAllocSizeCall(), getObjectType(), HandleSizeof(), clang::Type::isFunctionType(), clang::Type::isIncompleteType(), clang::QualType::isNull(), isUserWritingOffTheEnd(), and refersToCompleteObject().
Referenced by tryEvaluateBuiltinObjectSize().
|
static |
Diagnose an attempt to read from any unreadable field within the specified type, which might be a class type.
Definition at line 3486 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), clang::RecordDecl::fields(), clang::Type::getAsCXXRecordDecl(), clang::Type::getBaseElementTypeUnsafe(), clang::Expr::getType(), clang::CXXRecordDecl::hasMutableFields(), isReadByLvalueToRvalueConversion(), and clang::TagDecl::isUnion().
Referenced by findSubobject().
Definition at line 2670 of file ExprConstant.cpp.
References clang::Type::castAs(), Evaluate(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::Expr::getType(), clang::APValue::getVectorElt(), clang::APValue::getVectorLength(), clang::APValue::isFloat(), clang::APValue::isInt(), and clang::APValue::isVector().
Definition at line 2469 of file ExprConstant.cpp.
Referenced by HandleConversionToBool().
Definition at line 14749 of file ExprConstant.cpp.
References EvaluateArray(), EvaluateAtomic(), EvaluateComplex(), EvaluateFloat(), EvaluateLValue(), EvaluateMemberPointer(), EvaluatePointer(), EvaluateRecord(), EvaluateVector(), EvaluateVoid(), clang::QualType::getAtomicUnqualifiedType(), clang::Expr::getType(), clang::Type::hasPointerRepresentation(), clang::Type::isAnyComplexType(), clang::Type::isArrayType(), clang::Type::isAtomicType(), clang::Type::isFixedPointType(), clang::Type::isFunctionType(), clang::Expr::isGLValue(), clang::Type::isIntegralOrEnumerationType(), clang::Type::isMemberPointerType(), clang::Type::isRealFloatingType(), clang::Type::isRecordType(), clang::Expr::isValueDependent(), clang::Type::isVectorType(), clang::Type::isVoidType(), and P.
Referenced by EvalAndBitcastToAPInt(), EvaluateAsBooleanCondition(), EvaluateAsRValue(), EvaluateIgnoredValue(), EvaluateInPlace(), and handleLValueToRValueConversion().
|
static |
Evaluate the arguments to a function call.
Definition at line 6093 of file ExprConstant.cpp.
References EvaluateCallArg(), and clang::NonNull.
Referenced by HandleConstructorCall().
|
static |
Definition at line 10654 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isArrayType(), clang::Expr::isPRValue(), clang::Expr::isValueDependent(), and clang::interp::This().
Referenced by Evaluate(), and EvaluateInPlace().
|
static |
Definition at line 10672 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isArrayType(), clang::Expr::isPRValue(), clang::Expr::isValueDependent(), and clang::interp::This().
|
static |
Definition at line 10662 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isArrayType(), clang::Expr::isPRValue(), clang::Expr::isValueDependent(), and clang::interp::This().
Definition at line 2522 of file ExprConstant.cpp.
References Evaluate(), HandleConversionToBool(), clang::Expr::isPRValue(), and clang::Expr::isValueDependent().
Referenced by clang::Sema::diagnoseArgIndependentDiagnoseIfAttrs(), and EvaluateCond().
|
static |
Definition at line 14952 of file ExprConstant.cpp.
References EvaluateAsRValue(), clang::Expr::getType(), hasUnacceptableSideEffect(), clang::Type::isFixedPointType(), and clang::Expr::isValueDependent().
Referenced by clang::Expr::EvaluateAsFixedPoint().
|
static |
Definition at line 14936 of file ExprConstant.cpp.
References EvaluateAsRValue(), clang::Expr::getType(), hasUnacceptableSideEffect(), clang::Type::isIntegralOrEnumerationType(), and clang::Expr::isValueDependent().
Referenced by clang::Expr::EvaluateAsInt().
|
static |
Definition at line 14926 of file ExprConstant.cpp.
References EvaluateAsRValue(), FastEvaluateAsRValue(), and clang::Expr::isValueDependent().
EvaluateAsRValue - Try to evaluate this expression, performing an implicit lvalue-to-rvalue cast if it is an lvalue.
Definition at line 14862 of file ExprConstant.cpp.
References CheckConstantExpression(), CheckLiteralType(), CheckMemoryLeaks(), Evaluate(), clang::Expr::getExprLoc(), clang::Expr::getType(), handleLValueToRValueConversion(), clang::Expr::isGLValue(), clang::QualType::isNull(), and clang::Expr::isValueDependent().
Referenced by clang::Expr::EvaluateAsBooleanCondition(), EvaluateAsFixedPoint(), clang::Expr::EvaluateAsFloat(), EvaluateAsInt(), clang::Expr::EvaluateAsRValue(), EvaluateAsRValue(), EvaluateBuiltinConstantP(), clang::Expr::EvaluateForOverflow(), clang::Expr::EvaluateKnownConstInt(), clang::Expr::EvaluateKnownConstIntCheckOverflow(), clang::Expr::isEvaluatable(), and tryEvaluateBuiltinObjectSize().
|
static |
Definition at line 14613 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isAtomicType(), clang::Expr::isPRValue(), clang::Expr::isValueDependent(), and clang::interp::This().
Referenced by Evaluate(), and EvaluateInPlace().
|
static |
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
Definition at line 11345 of file ExprConstant.cpp.
|
static |
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
Definition at line 11203 of file ExprConstant.cpp.
EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to GCC as we can manage.
Definition at line 11383 of file ExprConstant.cpp.
References EvaluateAsRValue(), EvaluateBuiltinConstantPForLValue(), clang::Expr::getType(), clang::Type::isAnyComplexType(), clang::Type::isFloatingType(), clang::Type::isIntegralOrEnumerationType(), clang::Type::isNullPtrType(), clang::Type::isPointerType(), and V.
EvaluateBuiltinConstantPForLValue - Determine the result of __builtin_constant_p when applied to the given pointer.
A pointer is only "constant" if it is null (or a pointer cast to integer) or it points to the first character of a string literal.
Definition at line 11362 of file ExprConstant.cpp.
References clang::APValue::getLValueBase(), clang::APValue::getLValueOffset(), and clang::CharUnits::isZero().
Referenced by EvaluateBuiltinConstantP().
Definition at line 15976 of file ExprConstant.cpp.
References EvaluatePointer(), clang::Type::getPointeeType(), clang::Expr::getType(), clang::Type::hasPointerRepresentation(), and clang::Expr::isPRValue().
|
static |
Definition at line 6067 of file ExprConstant.cpp.
References EvaluateInPlace(), clang::Expr::getType(), clang::NonNull, and V.
Referenced by EvaluateArgs().
|
static |
Definition at line 12739 of file ExprConstant.cpp.
References clang::Equal, EvaluateComplex(), EvaluateFixedPointOrInteger(), EvaluateFloat(), EvaluateInteger(), EvaluateLValue(), EvaluateMemberPointer(), EvaluatePointer(), FindDesignatorMismatch(), clang::Decl::getAccess(), clang::BinaryOperator::getFPFeaturesInEffect(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::FieldDecl::getParent(), clang::CharUnits::getQuantity(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), HasSameBase(), clang::Type::isAnyComplexType(), clang::BinaryOperator::isAssignmentOp(), clang::BinaryOperator::isComparisonOp(), clang::BinaryOperator::isEqualityOp(), clang::Type::isFixedPointType(), clang::FPOptions::isFPConstrained(), clang::Type::isIncompleteType(), clang::Type::isIntegralOrEnumerationType(), IsLiteralLValue(), clang::Type::isMemberPointerType(), clang::Type::isNullPtrType(), isOnePastTheEndOfCompleteObject(), clang::Type::isPointerType(), clang::Type::isRealFloatingType(), clang::BinaryOperator::isRelationalOp(), clang::TagDecl::isUnion(), clang::Expr::isValueDependent(), clang::Type::isVoidPointerType(), IsWeakLValue(), and isZeroSized().
Definition at line 14085 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isAnyComplexType(), clang::Expr::isPRValue(), and clang::Expr::isValueDependent().
Referenced by Evaluate(), and EvaluateComparisonBinaryOperator().
|
static |
Evaluate a condition (either a variable declaration or an expression).
Definition at line 4898 of file ExprConstant.cpp.
References EvaluateAsBooleanCondition(), EvaluateDecl(), and clang::Expr::isValueDependent().
|
static |
Evaluate an expression as a C++11 integral constant expression.
Definition at line 15721 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), clang::Expr::getType(), clang::Expr::isCXX11ConstantExpr(), and clang::Type::isIntegralOrUnscopedEnumerationType().
Referenced by clang::Expr::getIntegerConstantExpr(), and clang::Expr::isIntegerConstantExpr().
Definition at line 4874 of file ExprConstant.cpp.
References EvaluateVarDecl().
Referenced by EvaluateCond(), and EvaluateSwitch().
Definition at line 4888 of file ExprConstant.cpp.
References clang::Expr::containsErrors(), and clang::Expr::isValueDependent().
Referenced by EvaluateSwitch(), and HandleConstructorCall().
|
static |
Definition at line 15052 of file ExprConstant.cpp.
References HandleDestruction(), and clang::Expr::EvalStatus::HasSideEffects.
Referenced by clang::VarDecl::evaluateDestruction().
Evaluate only a fixed point expression into an APResult.
Definition at line 11111 of file ExprConstant.cpp.
References clang::APValue::getFixedPoint(), clang::Expr::getType(), clang::APValue::isFixedPoint(), clang::Type::isFixedPointType(), and clang::Expr::isValueDependent().
Referenced by EvaluateFixedPointOrInteger().
|
static |
Evaluate an integer or fixed point expression into an APResult.
Definition at line 11127 of file ExprConstant.cpp.
References EvaluateFixedPoint(), EvaluateInteger(), clang::Expr::getType(), clang::Type::isFixedPointType(), clang::Type::isIntegerType(), and clang::Expr::isValueDependent().
Referenced by EvaluateComparisonBinaryOperator().
Definition at line 13826 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isPRValue(), clang::Type::isRealFloatingType(), and clang::Expr::isValueDependent().
Referenced by Evaluate(), and EvaluateComparisonBinaryOperator().
Evaluate an expression to see if it had side-effects, and discard its result.
true
if the caller should keep evaluating. Definition at line 1948 of file ExprConstant.cpp.
References Evaluate(), and clang::Expr::isValueDependent().
Referenced by HandleOperatorDeleteCall(), and HandleOperatorNewCall().
|
static |
EvaluateInPlace - Evaluate an expression in-place in an APValue.
In some cases, the in-place evaluation is essential, since later initializers for an object can indirectly refer to subobjects which were initialized earlier.
Definition at line 14834 of file ExprConstant.cpp.
References CheckLiteralType(), Evaluate(), EvaluateArray(), EvaluateAtomic(), EvaluateRecord(), clang::QualType::getAtomicUnqualifiedType(), clang::Expr::getType(), clang::Type::isArrayType(), clang::Type::isAtomicType(), clang::Expr::isPRValue(), clang::Type::isRecordType(), clang::Expr::isValueDependent(), and clang::interp::This().
Referenced by clang::Expr::EvaluateAsInitializer(), EvaluateCallArg(), EvaluateVarDecl(), and HandleConstructorCall().
Definition at line 11090 of file ExprConstant.cpp.
References EvaluateIntegerOrLValue(), clang::APValue::getInt(), clang::APValue::isInt(), and clang::Expr::isValueDependent().
Referenced by EvaluateComparisonBinaryOperator(), EvaluateFixedPointOrInteger(), EvaluateSwitch(), getAlignmentArgument(), getBuiltinAlignArguments(), and HandleOperatorNewCall().
EvaluateIntegerOrLValue - Evaluate an rvalue integral-typed expression, and produce either the integer value or a pointer.
GCC has a heinous extension which folds casts between pointer types and pointer-sized integral types. We support this by allowing the evaluation of an integer rvalue to produce a pointer (represented as an lvalue) instead. Some simple arithmetic on such values is supported (they are treated much like char*).
Definition at line 11083 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isIntegralOrEnumerationType(), clang::Expr::isPRValue(), and clang::Expr::isValueDependent().
Referenced by EvaluateInteger().
|
static |
Evaluate the body of a loop, and translate the result as appropriate.
Definition at line 4939 of file ExprConstant.cpp.
References EvaluateStmt().
|
static |
Evaluate an expression as an lvalue.
This can be legitimately called on expressions which are not glvalues, in three cases:
Definition at line 8203 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isFunctionType(), clang::Expr::isGLValue(), clang::Expr::isValueDependent(), and clang::Type::isVoidType().
Referenced by Evaluate(), clang::Expr::EvaluateAsLValue(), EvaluateComparisonBinaryOperator(), and EvaluateObjectArgument().
|
static |
Attempts to evaluate the given LValueBase as the result of a call to a function with the alloc_size attribute.
If it was possible to do so, this function will return true, make Result's Base point to said function call, and mark Result's Base as invalid.
Definition at line 8637 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::VarDecl::getAnyInitializer(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::QualType::isConstQualified(), and clang::VarDecl::isLocalVarDecl().
Definition at line 9714 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isMemberPointerType(), clang::Expr::isPRValue(), and clang::Expr::isValueDependent().
Referenced by Evaluate(), EvaluateComparisonBinaryOperator(), and HandleMemberPointerAccess().
Build an lvalue for the object argument of a member function call.
Definition at line 4620 of file ExprConstant.cpp.
References EvaluateLValue(), EvaluatePointer(), EvaluateTemporary(), and clang::interp::This().
Referenced by HandleMemberPointerAccess().
|
static |
Definition at line 8798 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::hasPointerRepresentation(), clang::Expr::isPRValue(), and clang::Expr::isValueDependent().
Referenced by Evaluate(), EvaluateBuiltinStrLen(), EvaluateComparisonBinaryOperator(), EvaluateObjectArgument(), getBuiltinAlignArguments(), HandleOperatorDeleteCall(), and tryEvaluateBuiltinObjectSize().
|
static |
Definition at line 10222 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isPRValue(), clang::Type::isRecordType(), clang::Expr::isValueDependent(), and clang::interp::This().
Referenced by Evaluate(), and EvaluateInPlace().
|
static |
Definition at line 5053 of file ExprConstant.cpp.
Referenced by EvaluateLoopBody(), EvaluateSwitch(), HandleConstructorCall(), HandleDestructionImpl(), and HandleFunctionCall().
|
static |
Evaluate a switch statement.
Definition at line 4963 of file ExprConstant.cpp.
References EvaluateDecl(), EvaluateDependentExpr(), EvaluateInteger(), clang::Expr::EvaluateKnownConstInt(), EvaluateStmt(), clang::SwitchCase::getBeginLoc(), clang::SwitchStmt::getBody(), clang::SwitchStmt::getCond(), clang::SwitchStmt::getConditionVariable(), clang::SwitchStmt::getInit(), clang::CaseStmt::getLHS(), clang::SwitchCase::getNextSwitchCase(), clang::CaseStmt::getRHS(), clang::SwitchStmt::getSwitchCaseList(), and clang::Expr::isValueDependent().
Evaluate an expression of record type as a temporary.
Definition at line 10279 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isPRValue(), clang::Type::isRecordType(), and clang::Expr::isValueDependent().
Referenced by EvaluateObjectArgument().
Definition at line 4846 of file ExprConstant.cpp.
References EvaluateInPlace(), getDefaultInitValue(), clang::VarDecl::getInit(), clang::ValueDecl::getType(), clang::VarDecl::hasLocalStorage(), clang::Type::isDependentType(), and clang::Expr::isValueDependent().
Referenced by EvaluateDecl().
|
static |
Try to evaluate the initializer for a variable declaration.
Info | Information about the ongoing evaluation. |
E | An expression to be used when printing diagnostics. |
VD | The variable whose initializer should be obtained. |
Version | The version of the variable within the frame. |
Frame | The frame in which the variable was created. Must be null if this variable is not local to the evaluation. |
Result | Filled in with a pointer to the value of the variable. |
Definition at line 3239 of file ExprConstant.cpp.
Referenced by findCompleteObject().
Definition at line 10323 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isPRValue(), and clang::Type::isVectorType().
Referenced by Evaluate().
Definition at line 14739 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isPRValue(), clang::Expr::isValueDependent(), and clang::Type::isVoidType().
Referenced by Evaluate().
Definition at line 3434 of file ExprConstant.cpp.
Referenced by HandleDestructionImpl().
|
static |
Definition at line 3411 of file ExprConstant.cpp.
|
static |
Extract the value of a character from a string literal.
Definition at line 3378 of file ExprConstant.cpp.
Referenced by handleLValueToRValueConversion().
|
static |
Extract the designated sub-object of an rvalue.
Definition at line 3835 of file ExprConstant.cpp.
References clang::threadSafety::AK_Read, clang::AK_ReadObjectRepresentation, findSubobject(), and clang::interp::Sub().
Referenced by handleLValueToRValueConversion().
|
static |
Definition at line 14891 of file ExprConstant.cpp.
References clang::ASTContext::getLangOpts(), clang::Expr::getType(), clang::Type::isArrayType(), clang::QualType::isNull(), clang::Expr::isPRValue(), and clang::Type::isRecordType().
Referenced by EvaluateAsRValue(), and clang::Expr::EvaluateForOverflow().
|
static |
Find the complete object to which an LValue refers.
Definition at line 3960 of file ExprConstant.cpp.
References Depth, evaluateVarDeclInit(), clang::APValue::getAsString(), clang::VarDecl::getDefinition(), clang::Decl::getLocation(), clang::VarDecl::hasDefinition(), isAnyAccess(), clang::QualType::isConstant(), clang::VarDecl::isConstexpr(), isFormalAccess(), clang::Type::isIntegralOrEnumerationType(), clang::Decl::isInvalidDecl(), clang::Type::isLiteralType(), isModification(), clang::QualType::isVolatileQualified(), lifetimeStartedInEvaluation(), NoteLValueLocation(), clang::SD_Static, and V.
Referenced by checkDynamicType(), handleAssignment(), handleCompoundAssignment(), HandleDestruction(), handleIncDec(), and handleLValueToRValueConversion().
|
static |
Find the position where two subobject designators diverge, or equivalently the length of the common initial subsequence.
Definition at line 3903 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Type::castAsArrayTypeUnsafe(), clang::ArrayType::getElementType(), clang::Type::isAnyComplexType(), clang::Type::isArrayType(), clang::QualType::isNull(), and min().
Referenced by AreElementsOfSameArray(), and EvaluateComparisonBinaryOperator().
SubobjectHandler::result_type findSubobject | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const CompleteObject & | Obj, | ||
const SubobjectDesignator & | Sub, | ||
SubobjectHandler & | handler | ||
) |
Find the designated sub-object of an rvalue.
Definition at line 3611 of file ExprConstant.cpp.
References clang::AK_Construct, diagnoseMutableFields(), clang::Expr::getExprLoc(), clang::Decl::getLocation(), clang::APValue::isAbsent(), clang::Type::isAnyComplexType(), clang::Type::isArrayType(), clang::FieldDecl::isBitField(), clang::QualType::isConstQualified(), isFormalAccess(), clang::APValue::isIndeterminate(), isModification(), clang::Type::isRecordType(), isValidIndeterminateAccess(), clang::QualType::isVolatileQualified(), clang::QualType::removeLocalConst(), clang::QualType::removeLocalVolatile(), clang::interp::Sub(), and truncateBitfieldValue().
Referenced by checkDynamicType(), extractSubobject(), handleCompoundAssignment(), HandleDestruction(), handleIncDec(), and modifySubobject().
|
static |
Get rounding mode to use in evaluation of the specified expression.
If rounding mode is unknown at compile time, still try to evaluate the expression. If the result is exact, it does not depend on rounding mode. So return "tonearest" mode instead of "dynamic".
Definition at line 2560 of file ExprConstant.cpp.
References clang::Expr::getFPFeaturesInEffect(), and clang::FPOptions::getRoundingMode().
Referenced by handleFloatFloatBinOp(), and HandleFloatToFloatCast().
|
static |
Evaluate the value of the alignment argument to __builtin_align_{up,down}, __builtin_is_aligned and __builtin_assume_aligned.
Definition at line 9048 of file ExprConstant.cpp.
References EvaluateInteger().
Referenced by getBuiltinAlignArguments().
|
static |
Definition at line 9017 of file ExprConstant.cpp.
References GetAlignOfType(), clang::Expr::getType(), and clang::Expr::IgnoreParens().
Referenced by getBaseAlignment().
|
static |
Definition at line 8990 of file ExprConstant.cpp.
References clang::Type::getAs(), clang::Type::getPointeeType(), clang::QualType::getQualifiers(), clang::QualType::getTypePtr(), and clang::Qualifiers::hasUnaligned().
Referenced by GetAlignOfExpr(), and getBaseAlignment().
|
static |
Definition at line 9038 of file ExprConstant.cpp.
References GetAlignOfExpr(), and GetAlignOfType().
|
static |
Definition at line 5652 of file ExprConstant.cpp.
Referenced by ComputeDynamicType(), and HandleVirtualDispatch().
|
static |
Get the base index of the given base class within an APValue representing the given derived class.
Definition at line 3364 of file ExprConstant.cpp.
|
static |
Definition at line 11750 of file ExprConstant.cpp.
References EvaluateInteger(), EvaluatePointer(), getAlignmentArgument(), clang::CallExpr::getArg(), clang::Expr::getType(), clang::APValue::hasValue(), clang::Type::isIntegralOrEnumerationType(), and clang::Type::isPointerType().
|
static |
Attempts to compute the number of bytes available at the pointer returned by a function with the alloc_size attribute.
Returns true if we were successful. Places an unsigned number into Result
.
This expects the given CallExpr to be a call to a function with an alloc_size attribute.
Definition at line 8576 of file ExprConstant.cpp.
References clang::Expr::EvaluateAsInt(), clang::ASTContext::getSizeType(), and clang::ASTContext::getTypeSize().
Referenced by determineEndOffset(), and getBytesReturnedByAllocSizeCall().
|
static |
Convenience function.
LVal's base must be a call to an alloc_size function.
Definition at line 8623 of file ExprConstant.cpp.
References getBytesReturnedByAllocSizeCall().
Get the value to use for a default-initialized object of type T.
Return false if it encounters something invalid.
Definition at line 4786 of file ExprConstant.cpp.
References distance(), and clang::Type::getAsCXXRecordDecl().
Referenced by clang::VarDecl::evaluateDestruction(), EvaluateVarDecl(), and HandleConstructorCall().
|
static |
Definition at line 2032 of file ExprConstant.cpp.
Referenced by IsWeakLValue(), and isZeroSized().
|
static |
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
Definition at line 11432 of file ExprConstant.cpp.
References clang::APValue::LValueBase::dyn_cast(), clang::APValue::LValueBase::getDynamicAllocType(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::APValue::LValueBase::getTypeInfoType(), and clang::APValue::LValueBase::is().
Referenced by clang::Sema::checkInitMethod(), and determineEndOffset().
|
static |
Definition at line 3594 of file ExprConstant.cpp.
References clang::QualType::addConst(), clang::QualType::addVolatile(), clang::QualType::isConstQualified(), and clang::QualType::isVolatileQualified().
|
static |
Definition at line 6716 of file ExprConstant.cpp.
References clang::Type::getAsCXXRecordDecl().
|
static |
Perform an assignment of Val to LVal. Takes ownership of Val.
Definition at line 4316 of file ExprConstant.cpp.
References clang::AK_Assign, findCompleteObject(), and modifySubobject().
Referenced by HandleFunctionCall().
HandleBaseToDerivedCast - Apply the given base-to-derived cast operation on the provided lvalue, which currently refers to the base object.
Definition at line 4748 of file ExprConstant.cpp.
References CastToDerivedClass(), clang::CSK_Derived, clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::CXXRecordDecl::getCanonicalDecl(), clang::Type::getPointeeType(), clang::Expr::getType(), and clang::CastExpr::path_size().
|
static |
Perform zero-initialization on an object of non-union class type.
C++11 [dcl.init]p5: To zero-initialize an object or reference of type T means: [...] – if T is a (possibly cv-qualified) non-union class type, each non-static data member and each base-class subobject is zero-initialized
Definition at line 9818 of file ExprConstant.cpp.
References distance(), clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::CXXRecordDecl::getNumBases(), clang::Decl::isInvalidDecl(), and clang::TagDecl::isUnion().
|
static |
Definition at line 2956 of file ExprConstant.cpp.
References clang::RISCV::Float, clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), and handleCompareOpForVectorHelper().
Referenced by handleVectorVectorBinOp().
|
static |
Definition at line 2923 of file ExprConstant.cpp.
Referenced by handleCompareOpForVector().
|
static |
Perform a compound assignment of LVal <op>= RVal.
Definition at line 4455 of file ExprConstant.cpp.
References clang::AK_Assign, findCompleteObject(), and findSubobject().
|
static |
Definition at line 6419 of file ExprConstant.cpp.
References EvaluateArgs(), HandleConstructorCall(), and clang::interp::This().
|
static |
Evaluate a constructor call.
Definition at line 6206 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases_begin(), clang::declaresSameEntity(), distance(), EvaluateDependentExpr(), EvaluateInPlace(), EvaluateStmt(), clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::Type::getAsCXXRecordDecl(), getDefaultInitValue(), clang::Expr::getExprLoc(), clang::FieldDecl::getFieldIndex(), clang::CXXRecordDecl::getNumBases(), clang::CXXRecordDecl::getNumVBases(), clang::FieldDecl::getParent(), clang::CXXBaseSpecifier::getType(), HandleLValueDirectBase(), HandleLValueMember(), handleTrivialCopy(), clang::FieldDecl::isBitField(), clang::Decl::isInvalidDecl(), isReadByLvalueToRvalueConversion(), clang::TagDecl::isUnion(), clang::CXXBaseSpecifier::isVirtual(), Ret(), clang::interp::This(), and truncateBitfieldValue().
Referenced by HandleConstructorCall().
Definition at line 2484 of file ExprConstant.cpp.
References EvalPointerValueAsBool(), clang::RISCV::Float, clang::APValue::getComplexFloatImag(), clang::APValue::getComplexFloatReal(), clang::APValue::getComplexIntImag(), clang::APValue::getComplexIntReal(), clang::APValue::getFixedPoint(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), and clang::APValue::getMemberPointerDecl().
Referenced by clang::Expr::EvaluateAsBooleanCondition(), and EvaluateAsBooleanCondition().
|
static |
Perform the adjustment from a value returned by a virtual function to a value of the statically expected type, which may be a pointer or reference to a base class of the returned type.
Definition at line 5782 of file ExprConstant.cpp.
References CastToBaseClass().
|
static |
Perform a destructor or pseudo-destructor call on the given object, which might in general not be a complete object.
Definition at line 6624 of file ExprConstant.cpp.
References clang::AK_Destroy, findCompleteObject(), findSubobject(), and clang::interp::This().
Referenced by EvaluateDestruction().
|
static |
Destroy and end the lifetime of the given complete object.
Definition at line 6632 of file ExprConstant.cpp.
References HandleDestructionImpl().
|
static |
Definition at line 6432 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), CheckConstexprFunction(), EvaluateStmt(), expandArray(), clang::RecordDecl::fields(), clang::APValue::getArrayInitializedElt(), clang::Type::getAsCXXRecordDecl(), clang::APValue::getAsString(), clang::FunctionDecl::getBody(), clang::CXXRecordDecl::getDestructor(), clang::ArrayType::getElementType(), clang::CXXRecordDecl::getNumBases(), clang::CXXRecordDecl::getNumVBases(), clang::ConstantArrayType::getSize(), clang::APValue::getStructBase(), clang::APValue::getStructField(), HandleLValueArrayAdjustment(), HandleLValueDirectBase(), HandleLValueMember(), clang::CXXRecordDecl::hasTrivialDestructor(), clang::RecordDecl::isAnonymousStructOrUnion(), clang::QualType::isDestructedType(), clang::Type::isNullPtrType(), clang::FunctionDecl::isTrivial(), clang::TagDecl::isUnion(), Ret(), clang::interp::This(), and clang::VK_PRValue.
Referenced by HandleDestruction().
|
static |
Apply the given dynamic cast operation on the provided lvalue.
This implements the hard case of dynamic_cast, requiring a "runtime check" to find a suitable target subobject.
Definition at line 5823 of file ExprConstant.cpp.
References clang::AK_DynamicCast, CastToDerivedClass(), ComputeDynamicType(), clang::Type::getPointeeCXXRecordDecl(), clang::Expr::getType(), clang::ExplicitCastExpr::getTypeAsWritten(), clang::Expr::isGLValue(), and clang::Type::isVoidPointerType().
|
static |
Perform the given binary floating-point operation, in-place, on LHS.
Definition at line 2845 of file ExprConstant.cpp.
References checkFloatingPointResult(), and getActiveRoundingMode().
Referenced by handleVectorVectorBinOp().
|
static |
Definition at line 2609 of file ExprConstant.cpp.
References checkFloatingPointResult(), and getActiveRoundingMode().
|
static |
Definition at line 2540 of file ExprConstant.cpp.
References HandleOverflow(), and clang::Type::isSignedIntegerOrEnumerationType().
|
static |
Evaluate a function call.
Definition at line 6151 of file ExprConstant.cpp.
References EvaluateStmt(), clang::CXXRecordDecl::getCaptureFields(), clang::FunctionDecl::getParamDecl(), clang::CXXMethodDecl::getParent(), clang::CXXMethodDecl::getThisType(), handleAssignment(), handleTrivialCopy(), clang::CXXMethodDecl::isCopyAssignmentOperator(), clang::FunctionDecl::isDefaulted(), clang::isLambdaCallOperator(), clang::CXXMethodDecl::isMoveAssignmentOperator(), isReadByLvalueToRvalueConversion(), clang::FunctionDecl::isTrivial(), clang::TagDecl::isUnion(), Ret(), and clang::interp::This().
|
static |
Perform an increment or decrement on LVal.
Definition at line 4603 of file ExprConstant.cpp.
References clang::AK_Decrement, clang::AK_Increment, findCompleteObject(), and findSubobject().
|
static |
Perform the given binary integer operation.
Definition at line 2743 of file ExprConstant.cpp.
References CheckedIntArithmetic(), clang::Expr::getType(), and HandleOverflow().
Referenced by handleVectorVectorBinOp().
|
static |
Definition at line 2634 of file ExprConstant.cpp.
References clang::FPOptions::isFPConstrained().
|
static |
Definition at line 2621 of file ExprConstant.cpp.
References clang::Type::isBooleanType(), and clang::Type::isUnsignedIntegerOrEnumerationType().
|
static |
Definition at line 2896 of file ExprConstant.cpp.
|
static |
Definition at line 2884 of file ExprConstant.cpp.
Referenced by handleLogicalOpForVector(), and handleVectorVectorBinOp().
|
static |
Definition at line 2909 of file ExprConstant.cpp.
References clang::RISCV::Float, clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), and handleLogicalOpForVector().
|
static |
Update a pointer value to model pointer arithmetic.
Info | - Information about the ongoing evaluation. |
E | - The expression being evaluated, for diagnostic purposes. |
LVal | - The pointer value to be updated. |
EltTy | - The pointee type represented by LVal. |
Adjustment | - The adjustment, in objects of type EltTy, to add. |
Definition at line 3194 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), and HandleSizeof().
Referenced by HandleDestructionImpl(), and HandleLValueArrayAdjustment().
|
static |
Definition at line 3205 of file ExprConstant.cpp.
References HandleLValueArrayAdjustment().
|
static |
Definition at line 3083 of file ExprConstant.cpp.
References CastToDerivedClass(), clang::ASTRecordLayout::getVBaseClassOffset(), HandleLValueDirectBase(), and clang::Decl::isInvalidDecl().
Referenced by HandleLValueBasePath().
|
static |
Definition at line 3108 of file ExprConstant.cpp.
References clang::Type::getAsCXXRecordDecl(), HandleLValueBase(), clang::CastExpr::path_begin(), and clang::CastExpr::path_end().
|
static |
Update an lvalue to refer to a component of a complex number.
Info | - Information about the ongoing evaluation. |
LVal | - The lvalue to be updated. |
EltTy | - The complex number's component type. |
Imag | - False for the real component, true for the imaginary. |
Definition at line 3217 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), and HandleSizeof().
|
static |
Definition at line 3069 of file ExprConstant.cpp.
References clang::Decl::isInvalidDecl().
Referenced by HandleConstructorCall(), HandleDestructionImpl(), HandleLValueBase(), and HandleMemberPointerAccess().
|
static |
Update LVal to refer to the given indirect field.
Definition at line 3153 of file ExprConstant.cpp.
References clang::IndirectFieldDecl::chain(), and HandleLValueMember().
|
static |
Update LVal to refer to the given field, which must be a member of the type currently described by LVal.
Definition at line 3138 of file ExprConstant.cpp.
References clang::FieldDecl::getFieldIndex(), clang::FieldDecl::getParent(), and clang::Decl::isInvalidDecl().
Referenced by HandleConstructorCall(), HandleDestructionImpl(), and HandleLValueIndirectMember().
|
static |
Perform an lvalue-to-rvalue conversion on the given glvalue.
This can also be used for 'lvalue-to-lvalue' conversions for looking up the glvalue referred to by an entity of reference type.
Info | - Information about the ongoing evaluation. |
Conv | - The expression for which we are performing the conversion. Used for diagnostics. |
Type | - The type of the glvalue (before stripping cv-qualifiers in the case of a non-class type). |
LVal | - The glvalue on which we are attempting to perform this action. |
RVal | - The produced value will be placed here. |
WantObjectRepresentation | - If true, we're looking for the object representation rather than the value, and in particular, there is no requirement that the result be fully initialized. |
Definition at line 4236 of file ExprConstant.cpp.
References clang::threadSafety::AK_Read, clang::AK_ReadObjectRepresentation, Evaluate(), extractStringLiteralCharacter(), extractSubobject(), findCompleteObject(), clang::Type::isArrayType(), and clang::QualType::isConstant().
Referenced by EvaluateAsRValue(), and handleTrivialCopy().
|
static |
Definition at line 4728 of file ExprConstant.cpp.
References EvaluateMemberPointer(), EvaluateObjectArgument(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), and HandleMemberPointerAccess().
|
static |
HandleMemberPointerAccess - Evaluate a member access operation and build an lvalue referring to the result.
Info | - Information about the ongoing evaluation. |
LV | - An lvalue referring to the base of the member pointer. |
RHS | - The member pointer expression. |
IncludeMember | - Specifies whether the member itself is included in the resulting LValue subobject designator. This is not possible when creating a bound member function. |
Definition at line 4646 of file ExprConstant.cpp.
References CastToDerivedClass(), EvaluateMemberPointer(), clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::CXXRecordDecl::getCanonicalDecl(), clang::Type::getPointeeType(), and HandleLValueDirectBase().
Referenced by HandleMemberPointerAccess().
Definition at line 6776 of file ExprConstant.cpp.
References CheckDeleteKind(), EvaluateIgnoredValue(), EvaluatePointer(), clang::CallExpr::getArg(), clang::Expr::getExprLoc(), and clang::CallExpr::getNumArgs().
Perform a call to 'perator new' or to ‘__builtin_operator_new’.
Definition at line 6646 of file ExprConstant.cpp.
References EvaluateIgnoredValue(), EvaluateInteger(), clang::CallExpr::getArg(), clang::Expr::getExprLoc(), clang::CallExpr::getNumArgs(), clang::CharUnits::getQuantity(), clang::Expr::getType(), HandleSizeof(), clang::Type::isFunctionType(), clang::Type::isIncompleteType(), and clang::Type::isNothrowT().
|
static |
Definition at line 2533 of file ExprConstant.cpp.
Referenced by CheckedIntArithmetic(), HandleFloatToIntCast(), and handleIntIntBinOp().
|
static |
Get the size of the given type in char units.
Definition at line 3163 of file ExprConstant.cpp.
References clang::Type::isConstantSizeType(), clang::Type::isDependentType(), clang::Type::isFunctionType(), and clang::Type::isVoidType().
Referenced by determineEndOffset(), HandleLValueArrayAdjustment(), HandleLValueComplexElement(), and HandleOperatorNewCall().
|
static |
Perform a trivial copy from Param, which is the parameter of a copy or move constructor or assignment operator.
Definition at line 6131 of file ExprConstant.cpp.
References clang::QualType::getNonReferenceType(), clang::ValueDecl::getType(), and handleLValueToRValueConversion().
Referenced by HandleConstructorCall(), and HandleFunctionCall().
|
static |
Handle a builtin simple-assignment or a call to a trivial assignment operator whose left-hand side might involve a union member access.
If it does, implicitly start the lifetime of any accessed union elements per C++20 [class.union]5.
Definition at line 5971 of file ExprConstant.cpp.
References clang::declaresSameEntity().
|
static |
Definition at line 10503 of file ExprConstant.cpp.
References clang::RISCV::Float, clang::APValue::getFloat(), clang::APValue::getInt(), clang::ASTContext::getIntWidth(), clang::APValue::getKind(), and clang::Type::isUnsignedIntegerType().
|
static |
Definition at line 2969 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::RISCV::Float, clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), clang::VectorType::getNumElements(), clang::Expr::getType(), clang::APValue::getVectorElt(), clang::APValue::getVectorLength(), handleCompareOpForVector(), handleFloatFloatBinOp(), handleIntIntBinOp(), handleLogicalOpForVector(), clang::Type::isFloatingType(), clang::Type::isIntegerType(), clang::APValue::isLValue(), clang::Type::isUnsignedIntegerType(), and clang::APValue::isVector().
|
static |
Perform virtual dispatch.
Definition at line 5717 of file ExprConstant.cpp.
References clang::AK_Destroy, clang::AK_MemberCall, ComputeDynamicType(), getBaseClassType(), clang::CXXMethodDecl::getCorrespondingMethodDeclaredInClass(), clang::FunctionDecl::getReturnType(), and clang::interp::This().
|
static |
Definition at line 2059 of file ExprConstant.cpp.
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Definition at line 14920 of file ExprConstant.cpp.
Referenced by EvaluateAsFixedPoint(), clang::Expr::EvaluateAsFloat(), EvaluateAsInt(), and clang::Expr::isEvaluatable().
Definition at line 6709 of file ExprConstant.cpp.
References clang::Type::getAsCXXRecordDecl().
A more selective version of E->IgnoreParenCasts for tryEvaluateBuiltinObjectSize.
This ignores some casts/parens that serve only to change the type of E. Ex. For E = (short*)((char*)(&foo))
, returns &foo
Always returns an RValue with a pointer representation.
Definition at line 11454 of file ExprConstant.cpp.
References clang::interp::Cast(), clang::Expr::getType(), clang::Type::hasPointerRepresentation(), clang::Expr::IgnoreParens(), and clang::Expr::isPRValue().
Referenced by tryEvaluateBuiltinObjectSize().
|
static |
Definition at line 1470 of file ExprConstant.cpp.
References isModification(), and isRead().
Referenced by findCompleteObject(), and isFormalAccess().
|
static |
Determine whether Base
, which is known to be a direct base class of Derived
, is a public base class.
Definition at line 5809 of file ExprConstant.cpp.
References clang::AS_public, clang::CXXRecordDecl::bases(), and clang::declaresSameEntity().
Should this call expression be treated as a constant?
Definition at line 1958 of file ExprConstant.cpp.
References clang::CallExpr::getBuiltinCallee().
Referenced by IsGlobalLValue().
|
static |
Definition at line 8835 of file ExprConstant.cpp.
References clang::NamedDecl::getIdentifier(), clang::DeclContext::getParent(), clang::Decl::isInStdNamespace(), and clang::IdentifierInfo::isStr().
|
static |
Checks to see if the given LValue's Designator is at the end of the LValue's record layout.
e.g. struct { struct { int a, b; } fst, snd; } obj; obj.fst // no obj.snd // yes obj.fst.a // no obj.fst.b // no obj.snd.a // no obj.snd.b // yes
Please note: this function is specialized for how __builtin_object_size views "objects".
If this encounters an invalid RecordDecl or otherwise cannot determine the correct result, it will always return true.
Definition at line 11490 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::ASTContext::getAsArrayType(), clang::ASTContext::getASTRecordLayout(), clang::ArrayType::getElementType(), clang::ASTRecordLayout::getFieldCount(), clang::FieldDecl::getFieldIndex(), clang::FieldDecl::getParent(), clang::Type::isArrayType(), clang::Type::isIncompleteArrayType(), and Parent.
Referenced by isUserWritingOffTheEnd().
|
static |
Is this an access per the C++ definition?
Definition at line 1475 of file ExprConstant.cpp.
References clang::AK_Construct, clang::AK_Destroy, and isAnyAccess().
Referenced by findCompleteObject(), and findSubobject().
|
static |
Definition at line 1965 of file ExprConstant.cpp.
References clang::APValue::LValueBase::dyn_cast(), clang::APValue::LValueBase::get(), clang::Stmt::getStmtClass(), clang::APValue::LValueBase::is(), IsConstantCall(), clang::CompoundLiteralExpr::isFileScope(), clang::Expr::isLValue(), and clang::SD_Static.
Referenced by CheckLValueConstantExpression(), and clang::Expr::EvalResult::isGlobalLValue().
|
static |
Definition at line 2036 of file ExprConstant.cpp.
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Definition at line 1452 of file ExprConstant.cpp.
References clang::AK_Assign, clang::AK_Construct, clang::AK_Decrement, clang::AK_Destroy, clang::AK_DynamicCast, clang::AK_Increment, clang::AK_MemberCall, clang::threadSafety::AK_Read, clang::AK_ReadObjectRepresentation, and clang::AK_TypeId.
Referenced by findCompleteObject(), findSubobject(), and isAnyAccess().
Definition at line 9100 of file ExprConstant.cpp.
References clang::Type::isChar8Type(), and clang::Type::isCharType().
|
static |
Determine whether this is a pointer past the end of the complete object referred to by the lvalue.
Definition at line 12391 of file ExprConstant.cpp.
References clang::ASTContext::getTypeSizeInChars(), and clang::Type::isIncompleteType().
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Definition at line 1448 of file ExprConstant.cpp.
References clang::threadSafety::AK_Read, and clang::AK_ReadObjectRepresentation.
Referenced by isAnyAccess(), clang::PipeType::isReadOnly(), and clang::PipeType::Profile().
|
static |
Determine whether a type would actually be read by an lvalue-to-rvalue conversion.
If it's of class type, we may assume that the copy operation is trivial. Note that this is never true for a union type with fields (because the copy always "reads" the active member) and always true for a non-class type.
Definition at line 3464 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), clang::RecordDecl::field_empty(), clang::RecordDecl::fields(), clang::CXXRecordDecl::isEmpty(), and clang::TagDecl::isUnion().
Referenced by diagnoseMutableFields(), HandleConstructorCall(), HandleFunctionCall(), and isReadByLvalueToRvalueConversion().
Definition at line 3460 of file ExprConstant.cpp.
References clang::Type::getAsCXXRecordDecl(), clang::Type::getBaseElementTypeUnsafe(), and isReadByLvalueToRvalueConversion().
|
static |
Attempts to detect a user writing into a piece of memory that's impossible to figure out the size of by just using types.
Definition at line 11582 of file ExprConstant.cpp.
References isDesignatorAtObjectEnd().
Referenced by determineEndOffset().
|
static |
Is this kind of axcess valid on an indeterminate object value?
Definition at line 1480 of file ExprConstant.cpp.
References clang::AK_Assign, clang::AK_Construct, clang::AK_Decrement, clang::AK_Destroy, clang::AK_DynamicCast, clang::AK_Increment, clang::AK_MemberCall, clang::threadSafety::AK_Read, clang::AK_ReadObjectRepresentation, and clang::AK_TypeId.
Referenced by findSubobject().
|
static |
Definition at line 2043 of file ExprConstant.cpp.
References GetLValueBaseDecl().
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Definition at line 2048 of file ExprConstant.cpp.
References clang::Decl::getASTContext(), GetLValueBaseDecl(), clang::ASTContext::getTypeSize(), clang::Type::isArrayType(), and clang::Type::isIncompleteType().
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Definition at line 3519 of file ExprConstant.cpp.
References clang::QualType::isConstQualified(), and clang::Type::isReferenceType().
Referenced by findCompleteObject().
Definition at line 10684 of file ExprConstant.cpp.
|
static |
Update the designated sub-object of an rvalue to the given value.
Definition at line 3893 of file ExprConstant.cpp.
References findSubobject(), and clang::interp::Sub().
Referenced by handleAssignment().
|
static |
Negate an APSInt in place, converting it to a signed form if necessary, and preserving its value (by extending by up to one bit as needed).
Definition at line 1842 of file ExprConstant.cpp.
|
static |
Definition at line 15308 of file ExprConstant.cpp.
Referenced by CheckICE().
|
static |
Definition at line 2073 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), clang::ParmVarDecl::getFunctionScopeIndex(), and clang::Decl::getLocation().
Referenced by CheckDeleteKind(), CheckLValueConstantExpression(), and findCompleteObject().
|
static |
Tests to see if the LValue has a user-specified designator (that isn't necessarily valid).
Note that this always returns 'true' if the LValue has an unsized array as its first designator entry, because there's currently no way to tell if the user typed *foo or foo[0].
Definition at line 11564 of file ExprConstant.cpp.
Referenced by determineEndOffset().
|
static |
Definition at line 2649 of file ExprConstant.cpp.
References clang::FieldDecl::getBitWidthValue(), and clang::FieldDecl::isBitField().
Referenced by findSubobject(), and HandleConstructorCall().
|
static |
Definition at line 13832 of file ExprConstant.cpp.
|
static |
Tries to evaluate the __builtin_object_size for E
.
If successful, returns true and stores the result in Size
.
If WasError
is non-null, this will report whether the failure to evaluate is to be treated as an Error in IntExprEvaluator.
Definition at line 11700 of file ExprConstant.cpp.
References determineEndOffset(), EvaluateAsRValue(), EvaluatePointer(), clang::Expr::getExprLoc(), ignorePointerCastsAndParens(), and clang::Expr::isGLValue().
|
static |
Definition at line 15310 of file ExprConstant.cpp.
Referenced by CheckICE().