clang
8.0.0
|
#include "clang/AST/APValue.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Expr.h"
#include "clang/AST/OSLog.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/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <functional>
#include "clang/AST/TypeNodes.def"
#include "clang/AST/BuiltinTypes.def"
#include "clang/Basic/OpenCLImageTypes.def"
#include "clang/Basic/OpenCLExtensionTypes.def"
#include "clang/AST/StmtNodes.inc"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "exprconstant" |
#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 | ABSTRACT_STMT(Node) |
#define | STMT(Node, Base) case Expr::Node##Class: |
#define | EXPR(Node, Base) |
Enumerations | |
enum | CheckSubobjectKind |
enum | AccessKinds { AK_Read, AK_Assign, AK_Increment, AK_Decrement } |
Kinds of access we can perform on an object, for diagnostics. More... | |
enum | EvalStmtResult |
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... | |
enum | ICEKind |
Functions | |
static bool | IsGlobalLValue (APValue::LValueBase B) |
static void | describeCall (CallStackFrame *Frame, raw_ostream &Out) |
Produce a string describing the given constexpr call. 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... | |
template<class KeyTy > | |
static APValue & | createTemporary (const KeyTy *Key, bool IsLifetimeExtended, LValue &LV, CallStackFrame &Frame) |
A helper function to create a temporary and set an LValue. 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 | IsStringLiteralCall (const CallExpr *E) |
Should this call expression be treated as a string literal? More... | |
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 | CheckLValueConstantExpression (EvalInfo &Info, SourceLocation Loc, QualType Type, const LValue &LVal, Expr::ConstExprUsage Usage) |
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, Expr::ConstExprUsage Usage) |
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, Expr::ConstExprUsage Usage=Expr::EvaluateForCodeGen) |
Check that this core constant expression value is a valid value for a constant expression. 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 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, 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 Expr *E, APFloat &LHS, BinaryOperatorKind Opcode, const APFloat &RHS) |
Perform the given binary floating-point operation, in-place, on LHS. More... | |
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 | 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 | handleLValueToRValueConversion (EvalInfo &Info, const Expr *Conv, QualType Type, const LValue &LVal, APValue &RVal) |
Perform an lvalue-to-rvalue conversion on the given glvalue. More... | |
static bool | evaluateVarDeclInit (EvalInfo &Info, const Expr *E, const VarDecl *VD, CallStackFrame *Frame, APValue *&Result, const LValue *LVal) |
Try to evaluate the initializer for a variable declaration. More... | |
static bool | IsConstNonVolatile (QualType T) |
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 Expr *Lit, APValue &Result) |
static void | expandArray (APValue &Array, unsigned Index) |
static bool | isReadByLvalueToRvalueConversion (QualType T) |
Determine whether a type would actually be read by an lvalue-to-rvalue conversion. More... | |
static bool | diagnoseUnreadableFields (EvalInfo &Info, const Expr *E, QualType T) |
Diagnose an attempt to read from any unreadable field within the specified type, which might be a class type. More... | |
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) |
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 | 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 Expr *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 | EvaluateVarDecl (EvalInfo &Info, const VarDecl *VD) |
static bool | EvaluateDecl (EvalInfo &Info, const Decl *D) |
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 | 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 | hasFields (const CXXRecordDecl *RD) |
Determine if a class has any fields that might need to be copied by a trivial copy or move operation. More... | |
static bool | EvaluateArgs (ArrayRef< const Expr *> Args, ArgVector &ArgValues, EvalInfo &Info) |
EvaluateArgs - Evaluate the arguments to a function call. More... | |
static bool | HandleFunctionCall (SourceLocation CallLoc, const FunctionDecl *Callee, const LValue *This, ArrayRef< const Expr *> Args, const Stmt *Body, EvalInfo &Info, APValue &Result, const LValue *ResultSlot) |
Evaluate a function call. More... | |
static bool | HandleConstructorCall (const Expr *E, const LValue &This, APValue *ArgValues, 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 | 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 CharUnits | GetAlignOfType (EvalInfo &Info, QualType T, UnaryExprOrTypeTrait ExprKind) |
static CharUnits | GetAlignOfExpr (EvalInfo &Info, const Expr *E, UnaryExprOrTypeTrait ExprKind) |
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 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... | |
template<typename LValue > | |
static bool | EvaluateBuiltinConstantPForLValue (const LValue &LV) |
EvaluateBuiltinConstantPForLValue - Determine the result of __builtin_constant_p when applied to the given lvalue. More... | |
static bool | EvaluateBuiltinConstantP (ASTContext &Ctx, 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 | 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 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 BUILTIN_TYPE | ( | ID, | |
SINGLETON_ID | |||
) |
#define DEBUG_TYPE "exprconstant" |
Definition at line 53 of file ExprConstant.cpp.
#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 | ( | ID, | |
BASE | |||
) | case Type::ID: |
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE | ( | ID, | |
BASE | |||
) | case Type::ID: |
#define PLACEHOLDER_TYPE | ( | ID, | |
SINGLETON_ID | |||
) | case BuiltinType::ID: break; |
#define SIGNED_TYPE | ( | ID, | |
SINGLETON_ID | |||
) | case BuiltinType::ID: return GCCTypeClass::Integer; |
#define STMT | ( | Node, | |
Base | |||
) | case Expr::Node##Class: |
#define TYPE | ( | ID, | |
BASE | |||
) |
enum AccessKinds |
Kinds of access we can perform on an object, for diagnostics.
Enumerator | |
---|---|
AK_Read | |
AK_Assign | |
AK_Increment | |
AK_Decrement |
Definition at line 1294 of file ExprConstant.cpp.
enum CheckSubobjectKind |
Definition at line 223 of file ExprConstant.cpp.
enum EvalStmtResult |
Definition at line 3840 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 7610 of file ExprConstant.cpp.
enum ICEKind |
Definition at line 11108 of file ExprConstant.cpp.
Definition at line 8911 of file ExprConstant.cpp.
|
static |
Determine whether the given subobject designators refer to elements of the same array object.
Definition at line 3108 of file ExprConstant.cpp.
References FindDesignatorMismatch().
Referenced by EvaluateComparisonBinaryOperator().
|
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 2350 of file ExprConstant.cpp.
References clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTRecordLayout::getVBaseClassOffset(), and clang::Decl::isInvalidDecl().
Referenced by HandleBaseToDerivedCast(), 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 1939 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Type::castAsArrayTypeUnsafe(), CheckLValueConstantExpression(), CheckMemberPointerConstantExpression(), clang::RecordDecl::fields(), clang::APValue::getArrayFiller(), clang::APValue::getArrayInitializedElt(), clang::APValue::getArrayInitializedElts(), clang::Type::getAs(), clang::ArrayType::getElementType(), clang::APValue::getStructBase(), clang::APValue::getStructField(), clang::ValueDecl::getType(), clang::APValue::getUnionField(), clang::APValue::getUnionValue(), clang::APValue::hasArrayFiller(), clang::APValue::isArray(), clang::APValue::isLValue(), clang::APValue::isMemberPointer(), clang::APValue::isStruct(), clang::APValue::isUninit(), and clang::APValue::isUnion().
Referenced by clang::Expr::EvaluateAsConstantExpr(), clang::Expr::EvaluateAsInitializer(), EvaluateAsRValue(), EvaluateComparisonBinaryOperator(), and EvaluateLValue().
|
static |
CheckConstexprFunction - Check that a function can be called in a constant expression.
Definition at line 4344 of file ExprConstant.cpp.
References bool, clang::InheritedConstructor::getConstructor(), clang::CXXConstructorDecl::getInheritedConstructor(), clang::Decl::getLocation(), clang::FunctionDecl::isConstexpr(), and clang::Decl::isInvalidDecl().
Referenced by HandleConstructorCall().
|
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 2197 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), clang::Expr::getType(), and HandleOverflow().
Referenced by handleIntIntBinOp().
|
static |
Definition at line 11132 of file ExprConstant.cpp.
Referenced by CheckICE().
|
static |
Definition at line 11145 of file ExprConstant.cpp.
References CheckEvalInICE(), clang::VarDecl::checkInitIsICE(), 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(), IsConstNonVolatile(), clang::Type::isIntegralOrEnumerationType(), clang::Expr::isRValue(), clang::Type::isSignedIntegerOrEnumerationType(), clang::Expr::isValueDependent(), clang::Type::isVariableArrayType(), NoDiag(), clang::Stmt::NoStmtClass, clang::UETT_SizeOf, 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 1905 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isLiteralType(), and clang::Expr::isRValue().
Referenced by EvaluateAsRValue(), EvaluateComparisonBinaryOperator(), and EvaluateInPlace().
|
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 1810 of file ExprConstant.cpp.
References clang::APValue::LValueBase::dyn_cast(), clang::Expr::EvaluateForCodeGen, IsGlobalLValue(), clang::Type::isReferenceType(), and NoteLValueLocation().
Referenced by CheckConstantExpression(), and clang::Expr::EvaluateAsLValue().
|
static |
Member pointers are constant expressions unless they point to a non-virtual dllimport member function.
Definition at line 1890 of file ExprConstant.cpp.
References clang::Expr::EvaluateForMangling, and clang::APValue::getMemberPointerDecl().
Referenced by CheckConstantExpression().
|
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 4319 of file ExprConstant.cpp.
References clang::Decl::getLocation(), clang::FunctionDecl::isConstexpr(), clang::CXXConstructorDecl::isDefaultConstructor(), and clang::FunctionDecl::isTrivial().
Converts the given APInt to CharUnits, assuming the APInt is unsigned.
Fails if the conversion would cause loss of precision.
Definition at line 8009 of file ExprConstant.cpp.
References clang::CharUnits::fromQuantity(), and max().
Referenced by determineEndOffset().
|
static |
A helper function to create a temporary and set an LValue.
Definition at line 1622 of file ExprConstant.cpp.
Referenced by Evaluate(), EvaluateLValue(), EvaluatePointer(), EvaluateRecord(), and EvaluateVarDecl().
|
static |
Produce a string describing the given constexpr call.
Definition at line 1640 of file ExprConstant.cpp.
References clang::ValueDecl::getType(), and clang::APValue::printPretty().
|
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 8024 of file ExprConstant.cpp.
References convertUnsignedAPIntToCharUnits(), getBytesReturnedByAllocSizeCall(), getObjectType(), HandleSizeof(), clang::Type::isFunctionType(), clang::Type::isIncompleteType(), clang::QualType::isNull(), isUserWritingOffTheEnd(), refersToCompleteObject(), and clang::Result.
Referenced by tryEvaluateBuiltinObjectSize().
Diagnose an attempt to read from any unreadable field within the specified type, which might be a class type.
Definition at line 2739 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), bool, 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 2146 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().
Referenced by EvaluateVector().
Definition at line 2008 of file ExprConstant.cpp.
References clang::APValue::LValueBase::dyn_cast(), clang::APValue::getLValueBase(), clang::APValue::getLValueOffset(), clang::ValueDecl::isWeak(), and clang::CharUnits::isZero().
Referenced by HandleConversionToBool().
Definition at line 10743 of file ExprConstant.cpp.
References clang::C, createTemporary(), 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::Type::isVectorType(), clang::Type::isVoidType(), and P.
Referenced by EvalAndBitcastToAPInt(), EvaluateArgs(), EvaluateAsBooleanCondition(), clang::Expr::EvaluateAsConstantExpr(), EvaluateAsRValue(), EvaluateComparisonBinaryOperator(), EvaluateComplex(), EvaluateIgnoredValue(), EvaluateInPlace(), HandleConstructorCall(), handleLValueToRValueConversion(), and isOnePastTheEndOfCompleteObject().
|
static |
EvaluateArgs - Evaluate the arguments to a function call.
Definition at line 4416 of file ExprConstant.cpp.
References Evaluate().
Referenced by HandleConstructorCall(), and HandleFunctionCall().
|
static |
Definition at line 7168 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isArrayType(), and clang::Expr::isRValue().
Referenced by Evaluate(), and EvaluateInPlace().
Definition at line 2057 of file ExprConstant.cpp.
References Evaluate(), HandleConversionToBool(), and clang::Expr::isRValue().
Referenced by EvaluateComparisonBinaryOperator(), EvaluateCond(), and HandleConstructorCall().
|
static |
Definition at line 10917 of file ExprConstant.cpp.
References EvaluateAsRValue(), clang::Expr::getType(), hasUnacceptableSideEffect(), clang::APValue::isInt(), clang::Type::isIntegralOrEnumerationType(), and clang::Expr::EvalResult::Val.
Referenced by clang::Expr::EvaluateAsInt().
EvaluateAsRValue - Try to evaluate this expression, performing an implicit lvalue-to-rvalue cast if it is an lvalue.
Definition at line 10852 of file ExprConstant.cpp.
References CheckConstantExpression(), CheckLiteralType(), Evaluate(), clang::Expr::getExprLoc(), clang::Expr::getType(), handleLValueToRValueConversion(), clang::Expr::isGLValue(), clang::QualType::isNull(), and clang::Result.
Referenced by clang::Expr::EvaluateAsBooleanCondition(), clang::Expr::EvaluateAsFloat(), EvaluateAsInt(), clang::Expr::EvaluateAsRValue(), EvaluateAsRValue(), clang::Expr::EvaluateForOverflow(), clang::Expr::EvaluateKnownConstInt(), clang::Expr::EvaluateKnownConstIntCheckOverflow(), clang::Expr::isEvaluatable(), and tryEvaluateBuiltinObjectSize().
|
static |
Definition at line 10908 of file ExprConstant.cpp.
References EvaluateAsRValue(), FastEvaluateAsRValue(), and clang::Expr::EvalResult::Val.
|
static |
Definition at line 10690 of file ExprConstant.cpp.
References clang::CallExpr::getBuiltinCallee(), clang::CastExpr::getCastKind(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::Type::isAtomicType(), and clang::Expr::isRValue().
Referenced by Evaluate(), and EvaluateInPlace().
|
static |
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
Definition at line 7641 of file ExprConstant.cpp.
References clang::Auto, Bool, ClassOrStruct, Complex, Enum, clang::QualType::getCanonicalType(), clang::BuiltinType::getKind(), clang::AtomicType::getValueType(), Integer, clang::Type::isDependentType(), None, Pointer, PointerToDataMember, PointerToMemberFunction, Union, and Void.
Referenced by EvaluateBuiltinClassifyType(), and tryEvaluateBuiltinObjectSize().
|
static |
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
Definition at line 7773 of file ExprConstant.cpp.
References EvaluateBuiltinClassifyType(), clang::CallExpr::getArg(), clang::CallExpr::getNumArgs(), clang::Expr::getType(), and None.
|
static |
EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to GCC as we can manage.
Definition at line 7798 of file ExprConstant.cpp.
References clang::Expr::EvaluateAsRValue(), EvaluateBuiltinConstantPForLValue(), clang::APValue::getKind(), clang::Expr::getType(), clang::Expr::EvalStatus::HasSideEffects, clang::APValue::Int, clang::Type::isAnyComplexType(), clang::Expr::isEvaluatable(), clang::Type::isFloatingType(), clang::Expr::isGLValue(), clang::Type::isIntegralOrEnumerationType(), clang::Type::isPointerType(), clang::APValue::LValue, clang::Result, and clang::Expr::EvalResult::Val.
Referenced by tryEvaluateBuiltinObjectSize().
|
static |
EvaluateBuiltinConstantPForLValue - Determine the result of __builtin_constant_p when applied to the given lvalue.
An lvalue is only "constant" if it is a pointer or reference to the first character of a string literal.
Definition at line 7791 of file ExprConstant.cpp.
Referenced by EvaluateBuiltinConstantP().
|
static |
Definition at line 9087 of file ExprConstant.cpp.
References AreElementsOfSameArray(), clang::OffsetOfNode::Array, clang::OffsetOfNode::Base, clang::C, clang::UnaryOperator::canOverflow(), clang::Type::castAs(), CheckConstantExpression(), CheckLiteralType(), clang::Equal, clang::Error, Evaluate(), EvaluateAsBooleanCondition(), EvaluateComplex(), EvaluateFloat(), EvaluateInteger(), EvaluateLValue(), EvaluateMemberPointer(), EvaluatePointer(), clang::OffsetOfNode::Field, FindDesignatorMismatch(), clang::Decl::getAccess(), GetAlignOfExpr(), GetAlignOfType(), clang::UnaryExprOrTypeTraitExpr::getArgumentExpr(), clang::UnaryExprOrTypeTraitExpr::getArgumentType(), clang::OffsetOfNode::getArrayExprIndex(), clang::Type::getAs(), clang::OffsetOfNode::getBase(), clang::ASTRecordLayout::getBaseClassOffset(), clang::CastExpr::getCastKind(), clang::OffsetOfExpr::getComponent(), clang::RecordType::getDecl(), clang::Decl::getDeclContext(), clang::ArrayType::getElementType(), clang::Expr::getExprLoc(), clang::BinaryOperator::getExprLoc(), clang::OffsetOfNode::getField(), clang::ASTRecordLayout::getFieldCount(), clang::FieldDecl::getFieldIndex(), clang::ASTRecordLayout::getFieldOffset(), clang::OffsetOfExpr::getIndexExpr(), clang::APValue::getInt(), clang::OffsetOfNode::getKind(), clang::UnaryExprOrTypeTraitExpr::getKind(), clang::AddrLabelExpr::getLabel(), clang::BinaryOperator::getLHS(), clang::QualType::getNonReferenceType(), clang::OffsetOfExpr::getNumComponents(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getOpcode(), clang::SizeOfPackExpr::getPackLength(), clang::FieldDecl::getParent(), clang::Type::getPointeeType(), clang::CharUnits::getQuantity(), clang::BinaryOperator::getRHS(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), clang::TypeSourceInfo::getType(), clang::Expr::getType(), clang::CXXBaseSpecifier::getType(), clang::ValueDecl::getType(), clang::UnaryExprOrTypeTraitExpr::getTypeOfArgument(), clang::OffsetOfExpr::getTypeSourceInfo(), clang::CXXNoexceptExpr::getValue(), clang::ComparisonCategoryInfo::getValueInfo(), clang::Greater, HandleFloatToIntCast(), HandleIntToIntCast(), handleLValueToRValueConversion(), HandleOverflow(), HandleSizeof(), HasSameBase(), clang::OffsetOfNode::Identifier, clang::Type::isAnyComplexType(), clang::UnaryExprOrTypeTraitExpr::isArgumentType(), clang::BinaryOperator::isAssignmentOp(), clang::BinaryOperator::isComparisonOp(), clang::Type::isComplexIntegerType(), clang::ComparisonCategoryInfo::isEquality(), clang::BinaryOperator::isEqualityOp(), clang::Type::isIncompleteType(), clang::Type::isIntegralOrEnumerationType(), clang::Decl::isInvalidDecl(), IsLiteralLValue(), clang::Type::isMemberPointerType(), clang::Type::isNullPtrType(), isOnePastTheEndOfCompleteObject(), clang::ComparisonCategoryInfo::isOrdered(), clang::Type::isPointerType(), clang::Type::isRealFloatingType(), clang::BinaryOperator::isRelationalOp(), clang::TagDecl::isUnion(), clang::Type::isVectorType(), clang::CXXBaseSpecifier::isVirtual(), clang::Type::isVoidPointerType(), IsWeakLValue(), clang::CharUnits::isZero(), isZeroSized(), clang::Less, clang::ComparisonCategoryInfo::makeWeakResult(), clang::Nonequal, clang::Result, clang::UETT_AlignOf, clang::UETT_OpenMPRequiredSimdAlign, clang::UETT_PreferredAlignOf, clang::UETT_SizeOf, clang::UETT_VecStep, and clang::Unordered.
Definition at line 10188 of file ExprConstant.cpp.
References abs(), clang::C, clang::Type::castAs(), clang::Error, Evaluate(), EvaluateFloat(), EvaluateInPlace(), EvaluateInteger(), clang::Type::getAs(), clang::CastExpr::getCastKind(), clang::InitListExpr::getInit(), clang::BinaryOperator::getLHS(), clang::InitListExpr::getNumInits(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::ImaginaryLiteral::getSubExpr(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), HandleFloatToFloatCast(), HandleFloatToIntCast(), HandleIntToFloatCast(), HandleIntToIntCast(), ilogb, clang::Type::isAnyComplexType(), clang::BinaryOperator::isAssignmentOp(), clang::Type::isComplexType(), clang::Type::isIntegerType(), clang::BinaryOperator::isPtrMemOp(), clang::Type::isRealFloatingType(), clang::Expr::isRValue(), clang::Result, and scalbn.
Referenced by Evaluate(), and EvaluateComparisonBinaryOperator().
|
static |
Evaluate a condition (either a variable declaration or an expression).
Definition at line 3901 of file ExprConstant.cpp.
References EvaluateAsBooleanCondition(), EvaluateDecl(), and EvaluateStmt().
|
static |
Evaluate an expression as a C++11 integral constant expression.
Definition at line 11534 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), clang::APValue::getInt(), clang::Expr::getType(), clang::Expr::isCXX11ConstantExpr(), clang::APValue::isInt(), clang::Type::isIntegralOrUnscopedEnumerationType(), and clang::Result.
Referenced by clang::Expr::isIntegerConstantExpr().
Definition at line 3885 of file ExprConstant.cpp.
References EvaluateVarDecl().
Referenced by EvaluateCond(), and EvaluateSwitch().
Definition at line 9957 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isRealFloatingType(), and clang::Expr::isRValue().
Referenced by Evaluate(), EvaluateComparisonBinaryOperator(), EvaluateComplex(), EvaluateVector(), and tryEvaluateBuiltinObjectSize().
Evaluate an expression to see if it had side-effects, and discard its result.
true
if the caller should keep evaluating. Definition at line 1678 of file ExprConstant.cpp.
References Evaluate().
Referenced by EvaluateLValue(), evaluateLValueAsAllocSize(), and HandleConstructorCall().
|
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 10824 of file ExprConstant.cpp.
References CheckLiteralType(), Evaluate(), EvaluateArray(), EvaluateAtomic(), EvaluateRecord(), clang::QualType::getAtomicUnqualifiedType(), clang::Expr::getType(), clang::Type::isArrayType(), clang::Type::isAtomicType(), clang::Type::isRecordType(), clang::Expr::isRValue(), and clang::Expr::isValueDependent().
Referenced by clang::Expr::EvaluateAsInitializer(), EvaluateComplex(), EvaluateLValue(), EvaluatePointer(), EvaluateRecord(), EvaluateVarDecl(), EvaluateVector(), and HandleConstructorCall().
Definition at line 7567 of file ExprConstant.cpp.
References EvaluateIntegerOrLValue(), clang::APValue::getInt(), clang::Expr::getType(), clang::APValue::isInt(), and clang::Type::isSignedIntegerOrEnumerationType().
Referenced by EvaluateComparisonBinaryOperator(), EvaluateComplex(), EvaluatePointer(), EvaluateSwitch(), EvaluateVector(), GetAlignOfExpr(), and tryEvaluateBuiltinObjectSize().
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 7561 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isIntegralOrEnumerationType(), and clang::Expr::isRValue().
Referenced by EvaluateInteger(), and EvaluatePointer().
|
static |
Evaluate the body of a loop, and translate the result as appropriate.
Definition at line 3938 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 5351 of file ExprConstant.cpp.
References CheckConstantExpression(), createTemporary(), clang::SubobjectAdjustment::DerivedToBaseAdjustment, clang::Error, EvaluateIgnoredValue(), EvaluateInPlace(), evaluateVarDeclInit(), clang::SubobjectAdjustment::FieldAdjustment, clang::ArraySubscriptExpr::getBase(), clang::MemberExpr::getBase(), clang::DeclRefExpr::getDecl(), clang::Decl::getDeclContext(), clang::Expr::getExprLoc(), clang::CXXTypeidExpr::getExprOperand(), clang::MemberExpr::getMemberDecl(), clang::Stmt::getSourceRange(), clang::MaterializeTemporaryExpr::getStorageDuration(), clang::MaterializeTemporaryExpr::GetTemporaryExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), HandleLValueBasePath(), HandleLValueMember(), handleLValueToRValueConversion(), HandleMemberPointerAccess(), clang::VarDecl::hasLocalStorage(), clang::CompoundLiteralExpr::isFileScope(), clang::Type::isFunctionType(), clang::Expr::isGLValue(), clang::isLambdaCallOperator(), clang::CXXTypeidExpr::isPotentiallyEvaluated(), clang::Type::isReferenceType(), clang::APValue::isUninit(), clang::Type::isVectorType(), clang::Type::isVoidType(), clang::SubobjectAdjustment::MemberPointerAdjustment, clang::Result, clang::SD_Automatic, and clang::SD_Static.
Referenced by Evaluate(), clang::Expr::EvaluateAsLValue(), EvaluateComparisonBinaryOperator(), evaluateLValueAsAllocSize(), EvaluateObjectArgument(), HandleConstructorCall(), and MaybeElementDependentArrayFiller().
|
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 5712 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::APValue::LValueBase::dyn_cast(), clang::Error, EvaluateIgnoredValue(), EvaluateLValue(), EvaluatePointer(), clang::VarDecl::getAnyInitializer(), clang::BlockExpr::getBlockDecl(), clang::ObjCBoxedExpr::getSubExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), HandleLValueMember(), handleLValueToRValueConversion(), clang::BlockDecl::hasCaptures(), clang::Expr::IgnoreParens(), clang::QualType::isConstQualified(), clang::CXXThisExpr::isImplicit(), clang::isLambdaCallOperator(), clang::VarDecl::isLocalVarDecl(), clang::APValue::LValueBase::isNull(), and clang::Result.
Referenced by EvaluatePointer().
Definition at line 6411 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Error, clang::Type::getAsCXXRecordDecl(), clang::CastExpr::getCastKind(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::Type::isMemberPointerType(), clang::Expr::isRValue(), clang::CastExpr::path_begin(), clang::CastExpr::path_empty(), clang::CastExpr::path_end(), and clang::Result.
Referenced by Evaluate(), EvaluateComparisonBinaryOperator(), and HandleMemberPointerAccess().
Build an lvalue for the object argument of a member function call.
Definition at line 3675 of file ExprConstant.cpp.
References EvaluateLValue(), EvaluatePointer(), EvaluateTemporary(), clang::Expr::getType(), clang::Expr::isGLValue(), clang::Type::isLiteralType(), and clang::Type::isPointerType().
Referenced by HandleConstructorCall(), and HandleMemberPointerAccess().
|
static |
Definition at line 5839 of file ExprConstant.cpp.
References clang::Type::castAs(), createTemporary(), EvaluateInPlace(), EvaluateInteger(), EvaluateIntegerOrLValue(), evaluateLValueAsAllocSize(), clang::CharUnits::fromQuantity(), clang::CastExpr::getCastKind(), clang::ArrayType::getElementType(), clang::APValue::getInt(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), HandleBaseToDerivedCast(), HandleLValueArrayAdjustment(), HandleLValueBasePath(), handleLValueToRValueConversion(), clang::Type::hasPointerRepresentation(), clang::Expr::isGLValue(), clang::APValue::isInt(), clang::Type::isPointerType(), clang::Expr::isRValue(), clang::Type::isVoidPointerType(), negateAsSigned(), Offset, and clang::Result.
Referenced by Evaluate(), EvaluateComparisonBinaryOperator(), evaluateLValueAsAllocSize(), EvaluateObjectArgument(), GetAlignOfExpr(), HandleConstructorCall(), and tryEvaluateBuiltinObjectSize().
|
static |
Definition at line 6877 of file ExprConstant.cpp.
References createTemporary(), EvaluateInPlace(), clang::CastExpr::getCastKind(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::Type::isRecordType(), and clang::Expr::isRValue().
Referenced by Evaluate(), and EvaluateInPlace().
|
static |
Definition at line 4020 of file ExprConstant.cpp.
References clang::Stmt::getStmtClass().
Referenced by EvaluateCond(), EvaluateLoopBody(), EvaluateSwitch(), HandleConstructorCall(), and HandleFunctionCall().
|
static |
Evaluate a switch statement.
Definition at line 3957 of file ExprConstant.cpp.
References EvaluateDecl(), 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(), and clang::SwitchStmt::getSwitchCaseList().
Evaluate an expression of record type as a temporary.
Definition at line 6932 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::UnaryOperator::getSubExpr(), clang::Expr::getType(), clang::Type::isRecordType(), clang::Expr::isRValue(), clang::APValue::isVector(), and clang::Result.
Referenced by EvaluateObjectArgument(), and HandleConstructorCall().
Definition at line 3856 of file ExprConstant.cpp.
References createTemporary(), EvaluateInPlace(), clang::DeclaratorDecl::getBeginLoc(), clang::VarDecl::getInit(), clang::ValueDecl::getType(), clang::VarDecl::hasLocalStorage(), clang::Expr::isValueDependent(), and clang::Result.
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. |
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 2537 of file ExprConstant.cpp.
References clang::VarDecl::checkInitIsICE(), clang::VarDecl::evaluateValue(), clang::VarDecl::getAnyInitializer(), clang::Stmt::getBeginLoc(), clang::Decl::getDeclContext(), clang::VarDecl::getEvaluatedValue(), clang::Decl::getLocation(), clang::VarDecl::isInitCapture(), clang::isLambdaCallOperator(), clang::Expr::isValueDependent(), and clang::ValueDecl::isWeak().
Referenced by EvaluateLValue(), and findCompleteObject().
Definition at line 6974 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Error, EvalAndBitcastToAPInt(), EvaluateFloat(), EvaluateInPlace(), EvaluateInteger(), clang::APValue::getArrayFiller(), clang::Type::getAs(), clang::CastExpr::getCastKind(), clang::ArrayType::getElementType(), clang::VectorType::getElementType(), clang::InitListExpr::getInit(), clang::VectorType::getNumElements(), clang::InitListExpr::getNumInits(), clang::ConstantArrayType::getSize(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::APValue::getVectorElt(), clang::APValue::getVectorLength(), clang::APValue::hasArrayFiller(), clang::APValue::isArray(), clang::Type::isIntegerType(), clang::APValue::isLValue(), clang::Type::isRealFloatingType(), clang::Expr::isRValue(), clang::Type::isSignedIntegerType(), clang::Type::isVectorType(), clang::Result, and v.
Referenced by Evaluate().
Definition at line 10734 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isRValue(), and clang::Type::isVoidType().
Referenced by Evaluate().
|
static |
Definition at line 2694 of file ExprConstant.cpp.
Definition at line 2671 of file ExprConstant.cpp.
|
static |
Extract the value of a character from a string literal.
Definition at line 2644 of file ExprConstant.cpp.
|
static |
Extract the designated sub-object of an rvalue.
Definition at line 3002 of file ExprConstant.cpp.
References AK_Assign, findSubobject(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::QualType::isConstQualified(), clang::APValue::isInt(), and clang::APValue::swap().
Referenced by HandleConstructorCall(), and handleLValueToRValueConversion().
|
static |
Definition at line 10873 of file ExprConstant.cpp.
References clang::ASTContext::getLangOpts(), clang::Expr::getType(), clang::Type::isArrayType(), clang::QualType::isNull(), clang::Type::isRecordType(), clang::Expr::isRValue(), and clang::Expr::EvalResult::Val.
Referenced by EvaluateAsRValue(), and clang::Expr::EvaluateForOverflow().
|
static |
Find the complete object to which an LValue refers.
Definition at line 3128 of file ExprConstant.cpp.
References AK_Read, evaluateVarDeclInit(), clang::QualType::getAddressSpace(), clang::VarDecl::getDefinition(), clang::Expr::getExprLoc(), clang::Decl::getLocation(), clang::ValueDecl::getType(), clang::VarDecl::hasDefinition(), clang::VarDecl::isConstexpr(), clang::QualType::isConstQualified(), clang::Type::isFloatingType(), clang::Type::isIntegralOrEnumerationType(), clang::Decl::isInvalidDecl(), clang::QualType::isVolatileQualified(), NoteLValueLocation(), clang::opencl_constant, clang::QualType::removeLocalConst(), and clang::SD_Static.
Referenced by handleAssignment(), handleCompoundAssignment(), handleIncDec(), and handleLValueToRValueConversion().
|
static |
Find the position where two subobject designators diverge, or equivalently the length of the common initial subsequence.
Definition at line 3072 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Type::castAsArrayTypeUnsafe(), clang::ComplexType::getElementType(), 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 2797 of file ExprConstant.cpp.
References AK_Read, diagnoseUnreadableFields(), clang::Type::isArrayType(), clang::FieldDecl::isBitField(), clang::Type::isRecordType(), clang::APValue::isUninit(), and truncateBitfieldValue().
Referenced by extractSubobject(), handleCompoundAssignment(), handleIncDec(), and modifySubobject().
|
static |
Definition at line 6017 of file ExprConstant.cpp.
References AK_Read, clang::Type::castAs(), EvaluateInteger(), EvaluatePointer(), clang::CharUnits::fromQuantity(), GetAlignOfType(), clang::CallExpr::getArg(), clang::APValue::getAsString(), clang::CallExpr::getBuiltinCallee(), clang::APValue::getInt(), clang::CallExpr::getNumArgs(), clang::Type::getPointeeType(), clang::CharUnits::getQuantity(), clang::Expr::getType(), handleAssignment(), HandleIntToIntCast(), HandleLValueArrayAdjustment(), handleLValueToRValueConversion(), HasSameBase(), clang::Expr::IgnoreParens(), clang::Type::isIncompleteType(), clang::APValue::isInt(), IsStringLiteralCall(), clang::QualType::isTriviallyCopyableType(), clang::diff::Move, Offset, clang::CharUnits::One(), clang::Result, and clang::UETT_AlignOf.
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Definition at line 5990 of file ExprConstant.cpp.
References clang::Type::getAs(), clang::Type::getPointeeType(), clang::QualType::getQualifiers(), clang::QualType::getTypePtr(), clang::Qualifiers::hasUnaligned(), clang::CharUnits::One(), clang::UETT_AlignOf, clang::UETT_PreferredAlignOf, and clang::LangOptions::Ver7.
Referenced by EvaluateComparisonBinaryOperator(), and GetAlignOfExpr().
|
static |
Get the base index of the given base class within an APValue representing the given derived class.
Definition at line 2630 of file ExprConstant.cpp.
References clang::CXXRecordDecl::getCanonicalDecl().
|
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 5651 of file ExprConstant.cpp.
References clang::Expr::EvaluateAsInt(), clang::CallExpr::getArg(), clang::APValue::getInt(), clang::CallExpr::getNumArgs(), clang::ASTContext::getSizeType(), clang::ASTContext::getTypeSize(), clang::Expr::SE_AllowSideEffects, and clang::Expr::EvalResult::Val.
Referenced by determineEndOffset(), and getBytesReturnedByAllocSizeCall().
|
static |
Convenience function.
LVal's base must be a call to an alloc_size function.
Definition at line 5698 of file ExprConstant.cpp.
References getBytesReturnedByAllocSizeCall().
|
static |
Definition at line 1749 of file ExprConstant.cpp.
Referenced by HasSameBase(), IsWeakLValue(), and isZeroSized().
|
static |
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
Definition at line 7842 of file ExprConstant.cpp.
References clang::APValue::LValueBase::dyn_cast(), clang::APValue::LValueBase::get(), clang::Expr::getType(), and clang::ValueDecl::getType().
Referenced by clang::Sema::checkInitMethod(), determineEndOffset(), clang::ObjCObjectPointerType::getInterfaceDecl(), clang::ObjCObjectPointerType::getInterfaceType(), clang::ObjCObjectPointerType::getNumProtocols(), clang::ObjCObjectPointerType::getProtocol(), clang::ObjCObjectPointerType::getSuperClassType(), clang::ObjCObjectPointerType::getTypeArgs(), clang::ObjCObjectPointerType::getTypeArgsAsWritten(), clang::ObjCObjectPointerType::isKindOfType(), clang::ObjCObjectPointerType::isObjCClassType(), clang::ObjCObjectPointerType::isObjCIdOrClassType(), clang::ObjCObjectPointerType::isObjCIdType(), clang::ObjCObjectPointerType::isObjCQualifiedClassType(), clang::ObjCObjectPointerType::isObjCQualifiedIdType(), clang::ObjCObjectPointerType::isSpecialized(), clang::ObjCObjectPointerType::isSpecializedAsWritten(), clang::ObjCObjectPointerType::isUnspecialized(), clang::ObjCObjectPointerType::qual_begin(), clang::ObjCObjectPointerType::qual_empty(), clang::ObjCObjectPointerType::qual_end(), and clang::ObjCObjectPointerType::stripObjCKindOfTypeAndQuals().
|
static |
Perform an assignment of Val to LVal. Takes ownership of Val.
Definition at line 3383 of file ExprConstant.cpp.
References AK_Assign, clang::APValue::ComplexFloat, clang::APValue::ComplexInt, findCompleteObject(), clang::APValue::Float, clang::Type::getAs(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), clang::Type::getPointeeType(), handleFloatFloatBinOp(), HandleFloatToFloatCast(), HandleFloatToIntCast(), handleIntIntBinOp(), HandleIntToFloatCast(), HandleIntToIntCast(), HandleLValueArrayAdjustment(), clang::APValue::Int, clang::QualType::isConstQualified(), clang::APValue::isFloat(), clang::APValue::isInt(), clang::Type::isIntegerType(), clang::QualType::isNull(), clang::APValue::LValue, modifySubobject(), negateAsSigned(), and Offset.
Referenced by GetAlignOfExpr(), HandleFunctionCall(), and tryEvaluateBuiltinObjectSize().
HandleBaseToDerivedCast - Apply the given base-to-derived cast operation on the provided lvalue, which currently refers to the base object.
Definition at line 3803 of file ExprConstant.cpp.
References CastToDerivedClass(), clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::CXXRecordDecl::getCanonicalDecl(), clang::Type::getPointeeType(), clang::Expr::getType(), and clang::CastExpr::path_size().
Referenced by EvaluatePointer(), and HandleConstructorCall().
|
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 6515 of file ExprConstant.cpp.
References distance(), clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::Decl::isInvalidDecl(), and clang::TagDecl::isUnion().
|
static |
Perform a compound assignment of LVal <op>= RVal.
Definition at line 3509 of file ExprConstant.cpp.
References AK_Assign, AK_Increment, clang::UnaryOperator::canOverflow(), clang::Type::castAs(), clang::APValue::ComplexFloat, clang::APValue::ComplexInt, findCompleteObject(), findSubobject(), clang::APValue::Float, clang::Type::getAs(), clang::APValue::getComplexFloatReal(), clang::APValue::getComplexIntReal(), clang::QualType::getCVRQualifiers(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), clang::Type::getPointeeType(), HandleLValueArrayAdjustment(), HandleOverflow(), clang::APValue::Int, clang::Type::isBooleanType(), clang::QualType::isConstQualified(), clang::Type::isIntegerType(), and clang::APValue::LValue.
|
static |
Evaluate a constructor call.
Definition at line 4493 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases_begin(), clang::C, distance(), EvaluateInPlace(), EvaluateStmt(), clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::FunctionDecl::getBody(), clang::Expr::getExprLoc(), clang::FieldDecl::getFieldIndex(), clang::QualType::getNonReferenceType(), clang::CXXRecordDecl::getNumBases(), clang::CXXRecordDecl::getNumVBases(), clang::FunctionDecl::getParamDecl(), clang::CXXMethodDecl::getParent(), clang::FieldDecl::getParent(), clang::APValue::getStructBase(), clang::APValue::getStructField(), clang::CXXBaseSpecifier::getType(), clang::ValueDecl::getType(), clang::APValue::getUnionField(), clang::APValue::getUnionValue(), HandleLValueDirectBase(), HandleLValueMember(), handleLValueToRValueConversion(), hasFields(), clang::CXXConstructorDecl::init_begin(), clang::CXXConstructorDecl::inits(), clang::FieldDecl::isBitField(), clang::CXXConstructorDecl::isCopyOrMoveConstructor(), clang::FunctionDecl::isDefaulted(), clang::CXXConstructorDecl::isDelegatingConstructor(), clang::Decl::isInvalidDecl(), clang::FunctionDecl::isTrivial(), clang::APValue::isUninit(), clang::APValue::isUnion(), clang::TagDecl::isUnion(), clang::CXXBaseSpecifier::isVirtual(), clang::Result, and truncateBitfieldValue().
Referenced by HandleConstructorCall().
|
static |
Definition at line 4649 of file ExprConstant.cpp.
References clang::CompoundStmt::body_begin(), clang::CompoundStmt::body_empty(), clang::CompoundStmt::body_end(), clang::CXXRecordDecl::captures_begin(), clang::CXXRecordDecl::captures_end(), clang::Type::castAs(), CheckConstexprFunction(), Diag(), clang::Error, Evaluate(), EvaluateArgs(), EvaluateAsBooleanCondition(), EvaluateIgnoredValue(), EvaluateLValue(), EvaluateObjectArgument(), EvaluatePointer(), EvaluateStmt(), EvaluateTemporary(), extractSubobject(), clang::FunctionTemplateDecl::findSpecialization(), clang::CallExpr::getArgs(), clang::Type::getAs(), clang::MemberExpr::getBase(), clang::FunctionDecl::getBody(), clang::CallExpr::getCallee(), clang::TagDecl::getCanonicalDecl(), clang::CastExpr::getCastKind(), clang::ChooseExpr::getChosenSubExpr(), clang::BinaryConditionalOperator::getCommon(), clang::ConditionalOperator::getCond(), clang::RecordType::getDecl(), clang::CXXDefaultArgExpr::getExpr(), clang::CXXDefaultInitExpr::getExpr(), clang::Expr::getExprLoc(), clang::ConditionalOperator::getFalseExpr(), clang::InitListExpr::getInit(), clang::CompoundLiteralExpr::getInitializer(), clang::CXXRecordDecl::getLambdaCallOperator(), clang::BinaryOperator::getLHS(), clang::MemberExpr::getMemberDecl(), clang::CallExpr::getNumArgs(), clang::InitListExpr::getNumInits(), clang::BinaryConditionalOperator::getOpaqueValue(), clang::BinaryOperator::getOpcode(), clang::DeclContext::getParent(), clang::CXXMethodDecl::getParent(), clang::FieldDecl::getParent(), clang::Type::getPointeeType(), clang::SubstNonTypeTemplateParmExpr::getReplacement(), clang::GenericSelectionExpr::getResultExpr(), clang::BinaryOperator::getRHS(), clang::OpaqueValueExpr::getSourceExpr(), clang::FullExpr::getSubExpr(), clang::ParenExpr::getSubExpr(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), clang::StmtExpr::getSubStmt(), clang::FunctionDecl::getTemplateSpecializationArgs(), clang::ConditionalOperator::getTrueExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), HandleBaseToDerivedCast(), HandleConstructorCall(), HandleFunctionCall(), handleIncDec(), HandleLValueBasePath(), HandleLValueIndirectMember(), HandleLValueMember(), handleLValueToRValueConversion(), HandleMemberPointerAccess(), clang::Expr::HasSideEffects(), clang::Expr::IgnoreParenCasts(), clang::Expr::IgnoreParens(), clang::MemberExpr::isArrow(), clang::Type::isFunctionPointerType(), clang::FunctionDecl::isFunctionTemplateSpecialization(), clang::CXXRecordDecl::isGenericLambda(), clang::UnaryOperator::isIncrementOp(), clang::CXXMethodDecl::isLambdaStaticInvoker(), clang::Type::isRecordType(), clang::Type::isReferenceType(), clang::Expr::isRValue(), clang::Type::isSpecificBuiltinType(), clang::CXXMethodDecl::isStatic(), and clang::Result.
Definition at line 2023 of file ExprConstant.cpp.
References clang::APValue::AddrLabelDiff, clang::APValue::Array, clang::APValue::ComplexFloat, clang::APValue::ComplexInt, EvalPointerValueAsBool(), clang::APValue::Float, clang::APValue::getComplexFloatImag(), clang::APValue::getComplexFloatReal(), clang::APValue::getComplexIntImag(), clang::APValue::getComplexIntReal(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), clang::APValue::getMemberPointerDecl(), clang::APValue::Int, clang::APValue::LValue, clang::APValue::MemberPointer, clang::APValue::Struct, clang::APValue::Uninitialized, clang::APValue::Union, and clang::APValue::Vector.
Referenced by clang::Expr::EvaluateAsBooleanCondition(), EvaluateAsBooleanCondition(), and isOnePastTheEndOfCompleteObject().
|
static |
Perform the given binary floating-point operation, in-place, on LHS.
Definition at line 2320 of file ExprConstant.cpp.
Referenced by handleAssignment().
|
static |
Definition at line 2089 of file ExprConstant.cpp.
References HandleOverflow(), and clang::Result.
Referenced by EvaluateComplex(), and handleAssignment().
|
static |
Definition at line 2074 of file ExprConstant.cpp.
References HandleOverflow(), and clang::Type::isSignedIntegerOrEnumerationType().
Referenced by EvaluateComparisonBinaryOperator(), EvaluateComplex(), and handleAssignment().
|
static |
Evaluate a function call.
Definition at line 4433 of file ExprConstant.cpp.
References EvaluateArgs(), EvaluateStmt(), clang::Decl::getEndLoc(), clang::FunctionDecl::getReturnType(), handleAssignment(), handleLValueToRValueConversion(), hasFields(), clang::isLambdaCallOperator(), clang::Type::isVoidType(), and clang::Result.
Referenced by HandleConstructorCall().
|
static |
Perform an increment or decrement on LVal.
Definition at line 3658 of file ExprConstant.cpp.
References AK_Decrement, AK_Increment, findCompleteObject(), and findSubobject().
Referenced by HandleConstructorCall().
|
static |
Perform the given binary integer operation.
Definition at line 2220 of file ExprConstant.cpp.
References CheckedIntArithmetic(), clang::Expr::getType(), and HandleOverflow().
Referenced by handleAssignment().
|
static |
Definition at line 2114 of file ExprConstant.cpp.
References HandleOverflow().
Referenced by EvaluateComplex(), and handleAssignment().
|
static |
Definition at line 2101 of file ExprConstant.cpp.
References clang::Type::isBooleanType(), clang::Type::isUnsignedIntegerOrEnumerationType(), and clang::Result.
Referenced by EvaluateComparisonBinaryOperator(), EvaluateComplex(), GetAlignOfExpr(), and handleAssignment().
|
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 2489 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), and HandleSizeof().
Referenced by EvaluatePointer(), GetAlignOfExpr(), handleAssignment(), handleCompoundAssignment(), HandleLValueArrayAdjustment(), and tryEvaluateBuiltinObjectSize().
|
static |
Definition at line 2500 of file ExprConstant.cpp.
References HandleLValueArrayAdjustment().
|
static |
Definition at line 2393 of file ExprConstant.cpp.
References CastToDerivedClass(), clang::Type::getAsCXXRecordDecl(), clang::CXXBaseSpecifier::getType(), clang::ASTRecordLayout::getVBaseClassOffset(), HandleLValueDirectBase(), clang::Decl::isInvalidDecl(), and clang::CXXBaseSpecifier::isVirtual().
Referenced by HandleLValueBasePath().
|
static |
Definition at line 2418 of file ExprConstant.cpp.
References clang::Type::getAsCXXRecordDecl(), HandleLValueBase(), clang::CastExpr::path_begin(), and clang::CastExpr::path_end().
Referenced by EvaluateLValue(), EvaluatePointer(), and HandleConstructorCall().
|
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 2512 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), handleLValueToRValueConversion(), and HandleSizeof().
|
static |
Definition at line 2379 of file ExprConstant.cpp.
References clang::Decl::isInvalidDecl().
Referenced by HandleConstructorCall(), HandleLValueBase(), and HandleMemberPointerAccess().
|
static |
Update LVal to refer to the given indirect field.
Definition at line 2448 of file ExprConstant.cpp.
References clang::C, clang::IndirectFieldDecl::chain(), and HandleLValueMember().
Referenced by HandleConstructorCall(), and HandleMemberPointerAccess().
|
static |
Update LVal to refer to the given field, which must be a member of the type currently described by LVal.
Definition at line 2433 of file ExprConstant.cpp.
References clang::FieldDecl::getFieldIndex(), clang::FieldDecl::getParent(), and clang::Decl::isInvalidDecl().
Referenced by EvaluateLValue(), evaluateLValueAsAllocSize(), HandleConstructorCall(), HandleLValueIndirectMember(), and HandleMemberPointerAccess().
|
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. |
Definition at line 3346 of file ExprConstant.cpp.
References AK_Read, Evaluate(), extractSubobject(), findCompleteObject(), clang::Expr::getType(), clang::QualType::isVolatileQualified(), and clang::CharUnits::Zero().
Referenced by EvaluateAsRValue(), EvaluateComparisonBinaryOperator(), EvaluateLValue(), evaluateLValueAsAllocSize(), EvaluatePointer(), GetAlignOfExpr(), HandleConstructorCall(), HandleFunctionCall(), HandleLValueComplexElement(), and tryEvaluateBuiltinObjectSize().
|
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 3701 of file ExprConstant.cpp.
References CastToDerivedClass(), EvaluateMemberPointer(), clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::CXXRecordDecl::getCanonicalDecl(), clang::Type::getPointeeType(), HandleLValueDirectBase(), HandleLValueIndirectMember(), and HandleLValueMember().
Referenced by EvaluateLValue(), HandleConstructorCall(), and HandleMemberPointerAccess().
|
static |
Definition at line 3783 of file ExprConstant.cpp.
References EvaluateMemberPointer(), EvaluateObjectArgument(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), and HandleMemberPointerAccess().
|
static |
Definition at line 2067 of file ExprConstant.cpp.
Referenced by CheckedIntArithmetic(), EvaluateComparisonBinaryOperator(), handleCompoundAssignment(), HandleFloatToFloatCast(), HandleFloatToIntCast(), handleIntIntBinOp(), and HandleIntToFloatCast().
|
static |
Get the size of the given type in char units.
Definition at line 2458 of file ExprConstant.cpp.
References clang::Type::isConstantSizeType(), clang::Type::isDependentType(), clang::Type::isFunctionType(), clang::Type::isVoidType(), and clang::CharUnits::One().
Referenced by determineEndOffset(), EvaluateComparisonBinaryOperator(), HandleLValueArrayAdjustment(), and HandleLValueComplexElement().
|
static |
Determine if a class has any fields that might need to be copied by a trivial copy or move operation.
Definition at line 4397 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), clang::RecordDecl::fields(), and clang::CXXRecordDecl::isEmpty().
Referenced by HandleConstructorCall(), and HandleFunctionCall().
|
static |
Definition at line 1776 of file ExprConstant.cpp.
References clang::Decl::getCanonicalDecl(), GetLValueBaseDecl(), and IsGlobalLValue().
Referenced by EvaluateComparisonBinaryOperator(), and GetAlignOfExpr().
|
static |
Definition at line 10902 of file ExprConstant.cpp.
References clang::Expr::EvalStatus::HasSideEffects, clang::Expr::EvalStatus::HasUndefinedBehavior, clang::Expr::SE_AllowSideEffects, and clang::Expr::SE_AllowUndefinedBehavior.
Referenced by clang::Expr::EvaluateAsFloat(), EvaluateAsInt(), and clang::Expr::isEvaluatable().
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 7860 of file ExprConstant.cpp.
References clang::CastExpr::getCastKind(), clang::Expr::getType(), clang::Type::hasPointerRepresentation(), clang::Expr::IgnoreParens(), and clang::Expr::isRValue().
Referenced by tryEvaluateBuiltinObjectSize().
Definition at line 2623 of file ExprConstant.cpp.
References clang::QualType::getQualifiers(), clang::Qualifiers::hasConst(), and clang::Qualifiers::hasVolatile().
Referenced by CheckICE().
|
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 7896 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::APValue::LValueBase::dyn_cast(), clang::ASTContext::getAsArrayType(), clang::ASTContext::getASTRecordLayout(), clang::ArrayType::getElementType(), clang::ASTRecordLayout::getFieldCount(), clang::FieldDecl::getFieldIndex(), clang::FieldDecl::getParent(), clang::Type::isArrayType(), clang::Type::isIncompleteArrayType(), clang::Decl::isInvalidDecl(), clang::TagDecl::isUnion(), and Parent.
Referenced by isUserWritingOffTheEnd().
|
static |
Definition at line 1693 of file ExprConstant.cpp.
References clang::APValue::LValueBase::dyn_cast(), clang::APValue::LValueBase::get(), clang::CompoundLiteralExpr::isFileScope(), clang::Expr::isLValue(), IsStringLiteralCall(), and clang::SD_Static.
Referenced by CheckLValueConstantExpression(), HasSameBase(), and clang::Expr::EvalResult::isGlobalLValue().
|
static |
Definition at line 1753 of file ExprConstant.cpp.
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Determine whether this is a pointer past the end of the complete object referred to by the lvalue.
Definition at line 8728 of file ExprConstant.cpp.
References clang::Error, Evaluate(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), clang::ASTContext::getTypeSizeInChars(), HandleConversionToBool(), clang::Expr::IgnoreParens(), clang::Type::isIncompleteType(), clang::Type::isIntegralOrEnumerationType(), clang::BinaryOperator::isLogicalOp(), clang::Expr::isRValue(), and clang::APValue::swap().
Referenced by EvaluateComparisonBinaryOperator().
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 2719 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), clang::RecordDecl::field_empty(), clang::RecordDecl::fields(), clang::Type::getAsCXXRecordDecl(), clang::Type::getBaseElementTypeUnsafe(), clang::CXXRecordDecl::isEmpty(), and clang::TagDecl::isUnion().
Referenced by diagnoseUnreadableFields().
Should this call expression be treated as a string literal?
Definition at line 1687 of file ExprConstant.cpp.
References clang::CallExpr::getBuiltinCallee().
Referenced by GetAlignOfExpr(), and IsGlobalLValue().
|
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 7988 of file ExprConstant.cpp.
References isDesignatorAtObjectEnd().
Referenced by determineEndOffset().
|
static |
Definition at line 1760 of file ExprConstant.cpp.
References GetLValueBaseDecl(), and clang::ValueDecl::isWeak().
Referenced by EvaluateComparisonBinaryOperator().
|
static |
Definition at line 1765 of file ExprConstant.cpp.
References clang::Decl::getASTContext(), GetLValueBaseDecl(), clang::ValueDecl::getType(), clang::ASTContext::getTypeSize(), clang::Type::isArrayType(), and clang::Type::isIncompleteType().
Referenced by EvaluateComparisonBinaryOperator().
Definition at line 7175 of file ExprConstant.cpp.
References clang::Error, EvaluateLValue(), clang::InitListExpr::getArrayFiller(), clang::InitListExpr::getInit(), clang::InitListExpr::getNumInits(), clang::ConstantArrayType::getSize(), clang::Expr::getType(), clang::InitListExpr::hasArrayFiller(), clang::InitListExpr::isStringLiteralInit(), and clang::APValue::isUninit().
|
static |
Update the designated sub-object of an rvalue to the given value.
Definition at line 3062 of file ExprConstant.cpp.
References findSubobject().
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 1631 of file ExprConstant.cpp.
Referenced by EvaluatePointer(), and handleAssignment().
|
static |
Definition at line 11128 of file ExprConstant.cpp.
Referenced by CheckICE().
|
static |
Definition at line 1797 of file ExprConstant.cpp.
References clang::APValue::LValueBase::dyn_cast(), clang::APValue::LValueBase::get(), clang::Expr::getExprLoc(), and clang::Decl::getLocation().
Referenced by 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 7970 of file ExprConstant.cpp.
Referenced by determineEndOffset().
|
static |
Definition at line 2125 of file ExprConstant.cpp.
References clang::FieldDecl::getBitWidthValue(), clang::APValue::getInt(), clang::FieldDecl::isBitField(), clang::APValue::isInt(), and clang::APValue::isLValue().
Referenced by findSubobject(), and HandleConstructorCall().
|
static |
Definition at line 9962 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 8106 of file ExprConstant.cpp.
References AK_Read, clang::analyze_os_log::computeOSLogBufferLayout(), determineEndOffset(), clang::Error, EvaluateAsRValue(), EvaluateBuiltinClassifyType(), EvaluateBuiltinConstantP(), EvaluateFloat(), EvaluateInteger(), clang::Expr::EvaluateKnownConstInt(), EvaluatePointer(), clang::CharUnits::fromQuantity(), clang::CallExpr::getArg(), clang::CallExpr::getBuiltinCallee(), clang::Expr::getExprLoc(), clang::APValue::getInt(), clang::Type::getPointeeType(), clang::CharUnits::getQuantity(), clang::Expr::getType(), handleAssignment(), HandleLValueArrayAdjustment(), handleLValueToRValueConversion(), clang::Expr::HasSideEffects(), clang::Expr::IgnoreImpCasts(), ignorePointerCastsAndParens(), clang::Expr::isGLValue(), clang::Type::isIncompleteType(), clang::APValue::isInt(), clang::Expr::isNullPointerConstant(), clang::CharUnits::isPowerOfTwo(), clang::Type::isSignedIntegerOrEnumerationType(), max(), clang::Expr::NPC_NeverValueDependent, clang::CharUnits::One(), clang::Result, and clang::analyze_os_log::OSLogBufferLayout::size().
|
static |
Definition at line 11130 of file ExprConstant.cpp.
Referenced by CheckICE().