clang API Documentation
#include "clang/AST/APValue.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Expr.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/SmallString.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <functional>
#include "clang/AST/StmtNodes.inc"
Go to the source code of this file.
Classes | |
struct | CompleteObject |
Defines | |
#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 | ICEKind |
Functions | |
static bool | IsGlobalLValue (APValue::LValueBase B) |
static void | describeCall (CallStackFrame *Frame, raw_ostream &Out) |
Produce a string describing the given constexpr call. | |
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. In some cases, the in-place evaluation is essential, since later initializers for an object can indirectly refer to subobjects which were initialized earlier. | |
static bool | EvaluateLValue (const Expr *E, LValue &Result, EvalInfo &Info) |
Evaluate an expression as an lvalue. This can be legitimately called on expressions which are not glvalues, in two cases: * function designators in C, and * "extern void" objects. | |
static bool | EvaluatePointer (const Expr *E, LValue &Result, EvalInfo &Info) |
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. | |
static bool | EvaluateInteger (const Expr *E, APSInt &Result, EvalInfo &Info) |
static bool | EvaluateIntegerOrLValue (const Expr *E, APValue &Result, EvalInfo &Info) |
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, APValue &Result, EvalInfo &Info) |
static bool | EvaluateIgnoredValue (EvalInfo &Info, const Expr *E) |
static int64_t | getExtValue (const APSInt &Value) |
static bool | IsStringLiteralCall (const CallExpr *E) |
Should this call expression be treated as a string literal? | |
static void | NoteLValueLocation (EvalInfo &Info, APValue::LValueBase Base) |
static bool | CheckLValueConstantExpression (EvalInfo &Info, SourceLocation Loc, QualType Type, const LValue &LVal) |
static bool | CheckLiteralType (EvalInfo &Info, const Expr *E, const LValue *This=nullptr) |
static bool | CheckConstantExpression (EvalInfo &Info, SourceLocation DiagLoc, QualType Type, const APValue &Value) |
const ValueDecl * | GetLValueBaseDecl (const LValue &LVal) |
static bool | IsLiteralLValue (const LValue &Value) |
static bool | IsWeakLValue (const LValue &Value) |
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 void | 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, 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 APSInt | CheckedIntArithmetic (EvalInfo &Info, const Expr *E, const APSInt &LHS, const APSInt &RHS, unsigned BitWidth, Operation Op) |
static bool | handleIntIntBinOp (EvalInfo &Info, const Expr *E, const APSInt &LHS, BinaryOperatorKind Opcode, APSInt RHS, APSInt &Result) |
Perform the given binary integer operation. | |
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. | |
static bool | CastToDerivedClass (EvalInfo &Info, const Expr *E, LValue &Result, const RecordDecl *TruncatedType, unsigned TruncatedElements) |
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) |
static bool | HandleLValueIndirectMember (EvalInfo &Info, const Expr *E, LValue &LVal, const IndirectFieldDecl *IFD) |
Update LVal to refer to the given indirect field. | |
static bool | HandleSizeof (EvalInfo &Info, SourceLocation Loc, QualType Type, CharUnits &Size) |
Get the size of the given type in char units. | |
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) |
static bool | evaluateVarDeclInit (EvalInfo &Info, const Expr *E, const VarDecl *VD, CallStackFrame *Frame, APValue *&Result) |
static bool | IsConstNonVolatile (QualType T) |
static unsigned | getBaseIndex (const CXXRecordDecl *Derived, const CXXRecordDecl *Base) |
static APSInt | extractStringLiteralCharacter (EvalInfo &Info, const Expr *Lit, uint64_t Index) |
Extract the value of a character from a string literal. | |
static void | expandStringLiteral (EvalInfo &Info, const Expr *Lit, APValue &Result) |
static void | expandArray (APValue &Array, unsigned Index) |
static bool | isReadByLvalueToRvalueConversion (QualType T) |
static bool | diagnoseUnreadableFields (EvalInfo &Info, const Expr *E, QualType T) |
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. | |
static bool | extractSubobject (EvalInfo &Info, const Expr *E, const CompleteObject &Obj, const SubobjectDesignator &Sub, APValue &Result) |
Extract the designated sub-object of an rvalue. | |
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. | |
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. | |
static bool | AreElementsOfSameArray (QualType ObjType, const SubobjectDesignator &A, const SubobjectDesignator &B) |
CompleteObject | findCompleteObject (EvalInfo &Info, const Expr *E, AccessKinds AK, const LValue &LVal, QualType LValType) |
Find the complete object to which an LValue refers. | |
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. This can also be used for 'lvalue-to-lvalue' conversions for looking up the glvalue referred to by an entity of reference type. | |
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. | |
static bool | isOverflowingIntegerType (ASTContext &Ctx, QualType T) |
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. | |
static bool | handleIncDec (EvalInfo &Info, const Expr *E, const LValue &LVal, QualType LValType, bool IsIncrement, APValue *Old) |
Perform an increment or decrement on LVal. | |
static bool | EvaluateObjectArgument (EvalInfo &Info, const Expr *Object, LValue &This) |
Build an lvalue for the object argument of a member function call. | |
static const ValueDecl * | HandleMemberPointerAccess (EvalInfo &Info, QualType LVType, LValue &LV, const Expr *RHS, bool IncludeMember=true) |
static const ValueDecl * | HandleMemberPointerAccess (EvalInfo &Info, const BinaryOperator *BO, LValue &LV, bool IncludeMember=true) |
static bool | HandleBaseToDerivedCast (EvalInfo &Info, const CastExpr *E, LValue &Result) |
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). | |
static EvalStmtResult | EvaluateStmt (APValue &Result, EvalInfo &Info, const Stmt *S, const SwitchCase *SC=nullptr) |
static EvalStmtResult | EvaluateLoopBody (APValue &Result, EvalInfo &Info, const Stmt *Body, const SwitchCase *Case=nullptr) |
Evaluate the body of a loop, and translate the result as appropriate. | |
static EvalStmtResult | EvaluateSwitch (APValue &Result, EvalInfo &Info, const SwitchStmt *SS) |
Evaluate a switch statement. | |
static bool | CheckTrivialDefaultConstructor (EvalInfo &Info, SourceLocation Loc, const CXXConstructorDecl *CD, bool IsValueInitialization) |
static bool | CheckConstexprFunction (EvalInfo &Info, SourceLocation CallLoc, const FunctionDecl *Declaration, const FunctionDecl *Definition) |
static bool | EvaluateArgs (ArrayRef< const Expr * > Args, ArgVector &ArgValues, EvalInfo &Info) |
EvaluateArgs - Evaluate the arguments to a function call. | |
static bool | HandleFunctionCall (SourceLocation CallLoc, const FunctionDecl *Callee, const LValue *This, ArrayRef< const Expr * > Args, const Stmt *Body, EvalInfo &Info, APValue &Result) |
Evaluate a function call. | |
static bool | HandleConstructorCall (SourceLocation CallLoc, const LValue &This, ArrayRef< const Expr * > Args, const CXXConstructorDecl *Definition, EvalInfo &Info, APValue &Result) |
Evaluate a constructor call. | |
static CharUnits | GetAlignOfType (EvalInfo &Info, QualType T) |
static CharUnits | GetAlignOfExpr (EvalInfo &Info, const Expr *E) |
static bool | HandleClassZeroInitialization (EvalInfo &Info, const Expr *E, const RecordDecl *RD, const LValue &This, APValue &Result) |
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 int | EvaluateBuiltinClassifyType (const CallExpr *E) |
template<typename LValue > | |
static bool | EvaluateBuiltinConstantPForLValue (const LValue &LV) |
static bool | EvaluateBuiltinConstantP (ASTContext &Ctx, const Expr *Arg) |
static bool | HasSameBase (const LValue &A, const LValue &B) |
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. | |
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 | 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. | |
static bool | FastEvaluateAsRValue (const Expr *Exp, Expr::EvalResult &Result, const ASTContext &Ctx, bool &IsConst) |
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. |
#define ABSTRACT_STMT | ( | Node | ) |
#define STMT | ( | Node, | |
Base | |||
) | case Expr::Node##Class: |
enum AccessKinds |
Kinds of access we can perform on an object, for diagnostics.
Definition at line 2144 of file ExprConstant.cpp.
enum CheckSubobjectKind |
Definition at line 145 of file ExprConstant.cpp.
enum EvalStmtResult |
Definition at line 3187 of file ExprConstant.cpp.
enum ICEKind |
Definition at line 8556 of file ExprConstant.cpp.
static bool AreElementsOfSameArray | ( | QualType | ObjType, |
const SubobjectDesignator & | A, | ||
const SubobjectDesignator & | B | ||
) | [static] |
Determine whether the given subobject designators refer to elements of the same array object.
Definition at line 2474 of file ExprConstant.cpp.
References FindDesignatorMismatch().
static bool CastToDerivedClass | ( | EvalInfo & | Info, |
const Expr * | E, | ||
LValue & | Result, | ||
const RecordDecl * | TruncatedType, | ||
unsigned | TruncatedElements | ||
) | [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 1759 of file ExprConstant.cpp.
References clang::CodeGen::Base, clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTRecordLayout::getVBaseClassOffset(), and clang::Decl::isInvalidDecl().
Referenced by HandleBaseToDerivedCast(), HandleLValueBase(), and HandleMemberPointerAccess().
static bool CheckConstantExpression | ( | EvalInfo & | Info, |
SourceLocation | DiagLoc, | ||
QualType | Type, | ||
const APValue & | Value | ||
) | [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 1348 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Type::castAsArrayTypeUnsafe(), CheckLValueConstantExpression(), 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::isStruct(), clang::APValue::isUninit(), and clang::APValue::isUnion().
Referenced by clang::Expr::EvaluateAsInitializer(), and EvaluateAsRValue().
static bool CheckConstexprFunction | ( | EvalInfo & | Info, |
SourceLocation | CallLoc, | ||
const FunctionDecl * | Declaration, | ||
const FunctionDecl * | Definition | ||
) | [static] |
CheckConstexprFunction - Check that a function can be called in a constant expression.
Definition at line 3628 of file ExprConstant.cpp.
References clang::Decl::getLocation(), clang::FunctionDecl::isConstexpr(), and clang::Decl::isInvalidDecl().
static APSInt CheckedIntArithmetic | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const APSInt & | LHS, | ||
const APSInt & | RHS, | ||
unsigned | BitWidth, | ||
Operation | Op | ||
) | [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 1612 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), clang::Expr::getType(), and HandleOverflow().
Referenced by handleIntIntBinOp().
static ICEDiag CheckEvalInICE | ( | const Expr * | E, |
const ASTContext & | Ctx | ||
) | [static] |
Definition at line 8580 of file ExprConstant.cpp.
References clang::Expr::EvaluateAsRValue(), clang::Stmt::getLocStart(), clang::Expr::EvalStatus::HasSideEffects, clang::APValue::isInt(), NoDiag(), and clang::Expr::EvalResult::Val.
Referenced by CheckICE().
static ICEDiag CheckICE | ( | const Expr * | E, |
const ASTContext & | Ctx | ||
) | [static] |
Definition at line 8589 of file ExprConstant.cpp.
References clang::BO_Add, clang::BO_AddAssign, clang::BO_And, clang::BO_AndAssign, clang::BO_Assign, clang::BO_Comma, clang::BO_Div, clang::BO_DivAssign, clang::BO_EQ, clang::BO_GE, clang::BO_GT, clang::BO_LAnd, clang::BO_LE, clang::BO_LOr, clang::BO_LT, clang::BO_Mul, clang::BO_MulAssign, clang::BO_NE, clang::BO_Or, clang::BO_OrAssign, clang::BO_PtrMemD, clang::BO_PtrMemI, clang::BO_Rem, clang::BO_RemAssign, clang::BO_Shl, clang::BO_ShlAssign, clang::BO_Shr, clang::BO_ShrAssign, clang::BO_Sub, clang::BO_SubAssign, clang::BO_Xor, clang::BO_XorAssign, CheckEvalInICE(), clang::VarDecl::checkInitIsICE(), clang::CK_AtomicToNonAtomic, clang::CK_IntegralCast, clang::CK_IntegralToBoolean, clang::CK_LValueToRValue, clang::CK_NonAtomicToAtomic, clang::CK_NoOp, clang::Expr::EvaluateKnownConstInt(), 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::Stmt::getLocStart(), 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::diag::Ignored, 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, clang::UO_AddrOf, clang::UO_Deref, clang::UO_Extension, clang::UO_Imag, clang::UO_LNot, clang::UO_Minus, clang::UO_Not, clang::UO_Plus, clang::UO_PostDec, clang::UO_PostInc, clang::UO_PreDec, clang::UO_PreInc, clang::UO_Real, and Worst().
Referenced by clang::Expr::isCXX98IntegralConstantExpr(), and clang::Expr::isIntegerConstantExpr().
static bool CheckLiteralType | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const LValue * | This = nullptr |
||
) | [static] |
Check that this core constant expression is of literal type, and if not, produce an appropriate diagnostic.
Definition at line 1324 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isLiteralType(), and clang::Expr::isRValue().
Referenced by EvaluateAsRValue(), and EvaluateInPlace().
static bool CheckLValueConstantExpression | ( | EvalInfo & | Info, |
SourceLocation | Loc, | ||
QualType | Type, | ||
const LValue & | LVal | ||
) | [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 1246 of file ExprConstant.cpp.
References IsGlobalLValue(), clang::Type::isReferenceType(), and NoteLValueLocation().
Referenced by CheckConstantExpression(), and clang::Expr::EvaluateAsLValue().
static bool CheckTrivialDefaultConstructor | ( | EvalInfo & | Info, |
SourceLocation | Loc, | ||
const CXXConstructorDecl * | CD, | ||
bool | IsValueInitialization | ||
) | [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 3603 of file ExprConstant.cpp.
References clang::Decl::getLocation(), clang::FunctionDecl::isConstexpr(), clang::CXXConstructorDecl::isDefaultConstructor(), and clang::FunctionDecl::isTrivial().
static void describeCall | ( | CallStackFrame * | Frame, |
raw_ostream & | Out | ||
) | [static] |
Produce a string describing the given constexpr call.
Definition at line 1117 of file ExprConstant.cpp.
References clang::ValueDecl::getType(), and clang::APValue::printPretty().
static bool diagnoseUnreadableFields | ( | EvalInfo & | Info, |
const Expr * | E, | ||
QualType | T | ||
) | [static] |
Diagnose an attempt to read from any unreadable field within the specified type, which might be a class type.
Definition at line 2110 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), clang::Type::getAsCXXRecordDecl(), clang::Type::getBaseElementTypeUnsafe(), clang::Expr::getType(), clang::CXXRecordDecl::hasMutableFields(), isReadByLvalueToRvalueConversion(), and clang::TagDecl::isUnion().
Referenced by findSubobject().
static bool EvalAndBitcastToAPInt | ( | EvalInfo & | Info, |
const Expr * | E, | ||
llvm::APInt & | Res | ||
) | [static] |
Definition at line 1561 of file ExprConstant.cpp.
References clang::Type::castAs(), Evaluate(), getElementType(), 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().
static bool EvalPointerValueAsBool | ( | const APValue & | Value, |
bool & | Result | ||
) | [static] |
Definition at line 1425 of file ExprConstant.cpp.
References clang::APValue::getLValueBase(), clang::APValue::getLValueOffset(), clang::ValueDecl::isWeak(), and clang::CharUnits::isZero().
Referenced by HandleConversionToBool().
Definition at line 8272 of file ExprConstant.cpp.
References AttributeLangSupport::C, EvaluateArray(), EvaluateAtomic(), EvaluateComplex(), EvaluateFloat(), EvaluateLValue(), EvaluateMemberPointer(), EvaluatePointer(), EvaluateRecord(), EvaluateVector(), EvaluateVoid(), clang::Expr::getType(), clang::Type::hasPointerRepresentation(), clang::Type::isAnyComplexType(), clang::Type::isArrayType(), clang::Type::isAtomicType(), 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(), EvaluateAsRValue(), EvaluateIgnoredValue(), EvaluateInPlace(), EvaluateStmt(), clang::Expr::EvaluateWithSubstitution(), handleLValueToRValueConversion(), and clang::Expr::isPotentialConstantExprUnevaluated().
static bool EvaluateArgs | ( | ArrayRef< const Expr * > | Args, |
ArgVector & | ArgValues, | ||
EvalInfo & | Info | ||
) | [static] |
EvaluateArgs - Evaluate the arguments to a function call.
Definition at line 3665 of file ExprConstant.cpp.
References Evaluate(), and clang::format::Success.
Referenced by HandleConstructorCall(), HandleFunctionCall(), and clang::Expr::isPotentialConstantExprUnevaluated().
static bool EvaluateArray | ( | const Expr * | E, |
const LValue & | This, | ||
APValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 5674 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isArrayType(), and clang::Expr::isRValue().
Referenced by Evaluate(), and EvaluateInPlace().
static bool EvaluateAsBooleanCondition | ( | const Expr * | E, |
bool & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 1474 of file ExprConstant.cpp.
References Evaluate(), HandleConversionToBool(), and clang::Expr::isRValue().
Referenced by EvaluateCond(), and EvaluateStmt().
static bool EvaluateAsRValue | ( | EvalInfo & | Info, |
const Expr * | E, | ||
APValue & | Result | ||
) | [static] |
EvaluateAsRValue - Try to evaluate this expression, performing an implicit lvalue-to-rvalue cast if it is an lvalue.
Definition at line 8367 of file ExprConstant.cpp.
References CheckConstantExpression(), CheckLiteralType(), Evaluate(), clang::Expr::getExprLoc(), clang::Expr::getType(), handleLValueToRValueConversion(), clang::Expr::isGLValue(), and clang::QualType::isNull().
static bool EvaluateAtomic | ( | const Expr * | E, |
APValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 8222 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isAtomicType(), and clang::Expr::isRValue().
Referenced by Evaluate().
static int EvaluateBuiltinClassifyType | ( | const CallExpr * | E | ) | [static] |
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
Definition at line 6017 of file ExprConstant.cpp.
References clang::CallExpr::getArg(), clang::CallExpr::getNumArgs(), clang::Expr::getType(), clang::Type::isArrayType(), clang::Type::isBooleanType(), clang::Type::isCharType(), clang::Type::isComplexType(), clang::Type::isEnumeralType(), clang::Type::isFunctionType(), clang::Type::isIntegerType(), clang::Type::isPointerType(), clang::Type::isRealType(), clang::Type::isReferenceType(), clang::Type::isStructureOrClassType(), clang::Type::isUnionType(), and clang::Type::isVoidType().
static bool EvaluateBuiltinConstantP | ( | ASTContext & | Ctx, |
const Expr * | Arg | ||
) | [static] |
EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to GCC as we can manage.
Definition at line 6083 of file ExprConstant.cpp.
References clang::Expr::EvaluateAsRValue(), EvaluateBuiltinConstantPForLValue(), EvaluateLValue(), EvaluatePointer(), clang::APValue::getKind(), clang::Expr::getType(), clang::Expr::EvalStatus::HasSideEffects, clang::Type::isAnyComplexType(), clang::Expr::isEvaluatable(), clang::Type::isFloatingType(), clang::Expr::isGLValue(), clang::Type::isIntegralOrEnumerationType(), clang::Type::isPointerType(), and clang::Expr::EvalResult::Val.
static bool EvaluateBuiltinConstantPForLValue | ( | const LValue & | LV | ) | [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 6076 of file ExprConstant.cpp.
Referenced by EvaluateBuiltinConstantP().
static bool EvaluateComplex | ( | const Expr * | E, |
ComplexValue & | Res, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 7731 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isAnyComplexType(), and clang::Expr::isRValue().
Referenced by Evaluate().
static bool EvaluateCond | ( | EvalInfo & | Info, |
const VarDecl * | CondDecl, | ||
const Expr * | Cond, | ||
bool & | Result | ||
) | [static] |
Evaluate a condition (either a variable declaration or an expression).
Definition at line 3236 of file ExprConstant.cpp.
References EvaluateAsBooleanCondition(), and EvaluateDecl().
Referenced by EvaluateStmt().
static bool EvaluateCPlusPlus11IntegralConstantExpr | ( | const ASTContext & | Ctx, |
const Expr * | E, | ||
llvm::APSInt * | Value, | ||
SourceLocation * | Loc | ||
) | [static] |
Evaluate an expression as a C++11 integral constant expression.
Definition at line 8961 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), clang::APValue::getInt(), clang::Expr::getType(), clang::Expr::isCXX11ConstantExpr(), clang::APValue::isInt(), and clang::Type::isIntegralOrEnumerationType().
Referenced by clang::Expr::isIntegerConstantExpr().
static bool EvaluateDecl | ( | EvalInfo & | Info, |
const Decl * | D | ||
) | [static] |
Definition at line 3203 of file ExprConstant.cpp.
References EvaluateInPlace(), clang::Decl::getLocStart(), and clang::Expr::isValueDependent().
Referenced by EvaluateCond(), EvaluateStmt(), and EvaluateSwitch().
static bool EvaluateFloat | ( | const Expr * | E, |
APFloat & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 7519 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isRealFloatingType(), and clang::Expr::isRValue().
Referenced by Evaluate().
static bool EvaluateIgnoredValue | ( | EvalInfo & | Info, |
const Expr * | E | ||
) | [static] |
Evaluate an expression to see if it had side-effects, and discard its result.
true
if the caller should keep evaluating. Definition at line 1155 of file ExprConstant.cpp.
References Evaluate().
Referenced by EvaluateStmt().
static bool EvaluateInPlace | ( | APValue & | Result, |
EvalInfo & | Info, | ||
const LValue & | This, | ||
const Expr * | E, | ||
bool | AllowNonLiteralTypes = false |
||
) | [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 8345 of file ExprConstant.cpp.
References CheckLiteralType(), Evaluate(), EvaluateArray(), EvaluateRecord(), clang::Expr::getType(), clang::Type::isArrayType(), clang::Type::isRecordType(), clang::Expr::isRValue(), and clang::Expr::isValueDependent().
Referenced by clang::Expr::EvaluateAsInitializer(), EvaluateDecl(), HandleClassZeroInitialization(), and HandleConstructorCall().
static bool EvaluateInteger | ( | const Expr * | E, |
APSInt & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 5974 of file ExprConstant.cpp.
References EvaluateIntegerOrLValue(), clang::APValue::getInt(), and clang::APValue::isInt().
Referenced by EvaluateSwitch().
static bool EvaluateIntegerOrLValue | ( | const Expr * | E, |
APValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
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 5968 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isIntegralOrEnumerationType(), and clang::Expr::isRValue().
Referenced by EvaluateInteger().
static EvalStmtResult EvaluateLoopBody | ( | APValue & | Result, |
EvalInfo & | Info, | ||
const Stmt * | Body, | ||
const SwitchCase * | Case = nullptr |
||
) | [static] |
Evaluate the body of a loop, and translate the result as appropriate.
Definition at line 3249 of file ExprConstant.cpp.
References EvaluateStmt().
Referenced by EvaluateStmt().
static bool EvaluateLValue | ( | const Expr * | E, |
LValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Evaluate an expression as an lvalue. This can be legitimately called on expressions which are not glvalues, in two cases: * function designators in C, and * "extern void" objects.
Definition at line 4461 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isFunctionType(), clang::Expr::isGLValue(), and clang::Type::isVoidType().
Referenced by Evaluate(), clang::Expr::EvaluateAsLValue(), EvaluateBuiltinConstantP(), and EvaluateObjectArgument().
static bool EvaluateMemberPointer | ( | const Expr * | E, |
MemberPtr & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 5030 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isMemberPointerType(), and clang::Expr::isRValue().
Referenced by Evaluate(), and HandleMemberPointerAccess().
static bool EvaluateObjectArgument | ( | EvalInfo & | Info, |
const Expr * | Object, | ||
LValue & | This | ||
) | [static] |
Build an lvalue for the object argument of a member function call.
Definition at line 3022 of file ExprConstant.cpp.
References EvaluateLValue(), EvaluatePointer(), EvaluateTemporary(), clang::Expr::getType(), clang::Expr::isGLValue(), clang::Type::isLiteralType(), and clang::Type::isPointerType().
Referenced by HandleMemberPointerAccess().
static bool EvaluatePointer | ( | const Expr * | E, |
LValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 4758 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::hasPointerRepresentation(), and clang::Expr::isRValue().
Referenced by Evaluate(), EvaluateBuiltinConstantP(), and EvaluateObjectArgument().
static bool EvaluateRecord | ( | const Expr * | E, |
const LValue & | This, | ||
APValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 5392 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isRecordType(), and clang::Expr::isRValue().
Referenced by Evaluate(), and EvaluateInPlace().
static EvalStmtResult EvaluateStmt | ( | APValue & | Result, |
EvalInfo & | Info, | ||
const Stmt * | S, | ||
const SwitchCase * | SC = nullptr |
||
) | [static] |
Definition at line 3325 of file ExprConstant.cpp.
References clang::CompoundStmt::body(), clang::DeclStmt::decls(), Evaluate(), EvaluateAsBooleanCondition(), EvaluateCond(), EvaluateDecl(), EvaluateIgnoredValue(), EvaluateLoopBody(), EvaluateSwitch(), clang::CXXForRangeStmt::getBeginEndStmt(), clang::CXXForRangeStmt::getBody(), clang::WhileStmt::getBody(), clang::DoStmt::getBody(), clang::ForStmt::getBody(), clang::CXXForRangeStmt::getCond(), clang::IfStmt::getCond(), clang::WhileStmt::getCond(), clang::DoStmt::getCond(), clang::ForStmt::getCond(), clang::IfStmt::getConditionVariable(), clang::WhileStmt::getConditionVariable(), clang::ForStmt::getConditionVariable(), clang::IfStmt::getElse(), clang::CXXForRangeStmt::getInc(), clang::ForStmt::getInc(), clang::ForStmt::getInit(), clang::Stmt::getLocStart(), clang::CXXForRangeStmt::getLoopVarStmt(), clang::CXXForRangeStmt::getRangeStmt(), clang::Stmt::getStmtClass(), clang::IfStmt::getThen(), and S.
Referenced by EvaluateLoopBody(), EvaluateSwitch(), HandleConstructorCall(), and HandleFunctionCall().
static EvalStmtResult EvaluateSwitch | ( | APValue & | Result, |
EvalInfo & | Info, | ||
const SwitchStmt * | SS | ||
) | [static] |
Evaluate a switch statement.
Definition at line 3268 of file ExprConstant.cpp.
References EvaluateDecl(), EvaluateInteger(), clang::Expr::EvaluateKnownConstInt(), EvaluateStmt(), clang::SwitchStmt::getBody(), clang::SwitchStmt::getCond(), clang::SwitchStmt::getConditionVariable(), clang::CaseStmt::getLHS(), clang::SwitchCase::getLocStart(), clang::SwitchCase::getNextSwitchCase(), clang::CaseStmt::getRHS(), and clang::SwitchStmt::getSwitchCaseList().
Referenced by EvaluateStmt().
static bool EvaluateTemporary | ( | const Expr * | E, |
LValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Evaluate an expression of record type as a temporary.
Definition at line 5442 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Type::isRecordType(), and clang::Expr::isRValue().
Referenced by EvaluateObjectArgument().
static bool evaluateVarDeclInit | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const VarDecl * | VD, | ||
CallStackFrame * | Frame, | ||
APValue *& | Result | ||
) | [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 1932 of file ExprConstant.cpp.
References clang::VarDecl::checkInitIsICE(), clang::VarDecl::evaluateValue(), clang::VarDecl::getAnyInitializer(), clang::VarDecl::getEvaluatedValue(), clang::Decl::getLocation(), clang::Expr::isValueDependent(), and clang::ValueDecl::isWeak().
Referenced by findCompleteObject().
static bool EvaluateVector | ( | const Expr * | E, |
APValue & | Result, | ||
EvalInfo & | Info | ||
) | [static] |
Definition at line 5484 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isRValue(), and clang::Type::isVectorType().
Referenced by Evaluate().
static bool EvaluateVoid | ( | const Expr * | E, |
EvalInfo & | Info | ||
) | [static] |
Definition at line 8263 of file ExprConstant.cpp.
References clang::Expr::getType(), clang::Expr::isRValue(), and clang::Type::isVoidType().
Referenced by Evaluate().
static void expandArray | ( | APValue & | Array, |
unsigned | Index | ||
) | [static] |
Definition at line 2065 of file ExprConstant.cpp.
References clang::APValue::getArrayFiller(), clang::APValue::getArrayInitializedElt(), clang::APValue::getArrayInitializedElts(), clang::APValue::getArraySize(), clang::APValue::hasArrayFiller(), and clang::APValue::swap().
Referenced by findSubobject().
static void expandStringLiteral | ( | EvalInfo & | Info, |
const Expr * | Lit, | ||
APValue & | Result | ||
) | [static] |
Definition at line 2042 of file ExprConstant.cpp.
References clang::APValue::getArrayFiller(), clang::APValue::getArrayInitializedElt(), clang::APValue::getArrayInitializedElts(), clang::StringLiteral::getCharByteWidth(), clang::StringLiteral::getCodeUnit(), clang::StringLiteral::getLength(), clang::Expr::getType(), clang::APValue::hasArrayFiller(), clang::Type::isIntegerType(), and clang::Type::isUnsignedIntegerType().
Referenced by findSubobject().
static APSInt extractStringLiteralCharacter | ( | EvalInfo & | Info, |
const Expr * | Lit, | ||
uint64_t | Index | ||
) | [static] |
Extract the value of a character from a string literal.
Definition at line 2022 of file ExprConstant.cpp.
References clang::StringLiteral::getCharByteWidth(), clang::StringLiteral::getCodeUnit(), clang::Expr::getType(), clang::Type::isIntegerType(), and clang::Type::isUnsignedIntegerType().
static bool extractSubobject | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const CompleteObject & | Obj, | ||
const SubobjectDesignator & | Sub, | ||
APValue & | Result | ||
) | [static] |
Extract the designated sub-object of an rvalue.
Definition at line 2368 of file ExprConstant.cpp.
References findSubobject().
Referenced by handleLValueToRValueConversion().
static bool FastEvaluateAsRValue | ( | const Expr * | Exp, |
Expr::EvalResult & | Result, | ||
const ASTContext & | Ctx, | ||
bool & | IsConst | ||
) | [static] |
Definition at line 8388 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 clang::Expr::EvaluateAsRValue(), and clang::Expr::EvaluateForOverflow().
CompleteObject findCompleteObject | ( | EvalInfo & | Info, |
const Expr * | E, | ||
AccessKinds | AK, | ||
const LValue & | LVal, | ||
QualType | LValType | ||
) |
Find the complete object to which an LValue refers.
Definition at line 2494 of file ExprConstant.cpp.
References AK_Read, evaluateVarDeclInit(), clang::VarDecl::getDefinition(), clang::Expr::getExprLoc(), clang::Decl::getLocation(), clang::VarDecl::isConstexpr(), clang::QualType::isConstQualified(), clang::Type::isFloatingType(), clang::Type::isIntegralOrEnumerationType(), clang::Decl::isInvalidDecl(), clang::QualType::isVolatileQualified(), NoteLValueLocation(), clang::QualType::removeLocalConst(), and clang::SD_Static.
Referenced by handleAssignment(), handleCompoundAssignment(), handleIncDec(), and handleLValueToRValueConversion().
static unsigned FindDesignatorMismatch | ( | QualType | ObjType, |
const SubobjectDesignator & | A, | ||
const SubobjectDesignator & | B, | ||
bool & | WasArrayIndex | ||
) | [static] |
Find the position where two subobject designators diverge, or equivalently the length of the common initial subsequence.
Definition at line 2438 of file ExprConstant.cpp.
References clang::Type::castAs(), clang::Type::castAsArrayTypeUnsafe(), clang::ComplexType::getElementType(), clang::ArrayType::getElementType(), clang::Type::isAnyComplexType(), clang::Type::isArrayType(), and clang::QualType::isNull().
Referenced by AreElementsOfSameArray().
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 2171 of file ExprConstant.cpp.
References clang::QualType::addConst(), AK_Read, clang::Type::castAs(), diagnoseUnreadableFields(), expandArray(), expandStringLiteral(), clang::APValue::getArrayFiller(), clang::APValue::getArrayInitializedElt(), clang::APValue::getArrayInitializedElts(), clang::Type::getAsCXXRecordDecl(), getBaseIndex(), clang::FieldDecl::getCanonicalDecl(), clang::APValue::getComplexFloatImag(), clang::APValue::getComplexFloatReal(), clang::APValue::getComplexIntImag(), clang::APValue::getComplexIntReal(), clang::ArrayType::getElementType(), getElementType(), clang::APValue::getLValueBase(), clang::APValue::getLValuePath(), clang::ConstantArrayType::getSize(), clang::APValue::getStructBase(), clang::APValue::getStructField(), clang::APValue::getUnionField(), clang::APValue::getUnionValue(), clang::APValue::hasLValuePath(), clang::Type::isAnyComplexType(), clang::Type::isArrayType(), clang::FieldDecl::isBitField(), clang::APValue::isComplexFloat(), clang::APValue::isComplexInt(), clang::QualType::isConstQualified(), clang::APValue::isLValue(), clang::Type::isRecordType(), clang::APValue::isUninit(), clang::TagDecl::isUnion(), clang::QualType::isVolatileQualified(), truncateBitfieldValue(), CompleteObject::Type, and CompleteObject::Value.
Referenced by extractSubobject(), handleCompoundAssignment(), handleIncDec(), and modifySubobject().
static CharUnits GetAlignOfExpr | ( | EvalInfo & | Info, |
const Expr * | E | ||
) | [static] |
Definition at line 4902 of file ExprConstant.cpp.
References GetAlignOfType(), clang::Expr::getType(), and clang::Expr::IgnoreParens().
static CharUnits GetAlignOfType | ( | EvalInfo & | Info, |
QualType | T | ||
) | [static] |
Definition at line 4890 of file ExprConstant.cpp.
References clang::Type::getAs(), clang::Type::getPointeeType(), and clang::QualType::getTypePtr().
Referenced by GetAlignOfExpr().
static unsigned getBaseIndex | ( | const CXXRecordDecl * | Derived, |
const CXXRecordDecl * | Base | ||
) | [static] |
Get the base index of the given base class within an APValue representing the given derived class.
Definition at line 2008 of file ExprConstant.cpp.
References clang::CodeGen::Base, clang::CXXRecordDecl::bases_begin(), clang::CXXRecordDecl::bases_end(), and clang::CXXRecordDecl::getCanonicalDecl().
Referenced by findSubobject().
static int64_t getExtValue | ( | const APSInt & | Value | ) | [static] |
Sign- or zero-extend a value to 64 bits. If it's already 64 bits, just return its existing value.
Definition at line 1165 of file ExprConstant.cpp.
const ValueDecl* GetLValueBaseDecl | ( | const LValue & | LVal | ) |
Definition at line 1409 of file ExprConstant.cpp.
Referenced by HasSameBase(), and IsWeakLValue().
static bool handleAssignment | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const LValue & | LVal, | ||
QualType | LValType, | ||
APValue & | Val | ||
) | [static] |
Perform an assignment of Val to LVal. Takes ownership of Val.
Definition at line 2735 of file ExprConstant.cpp.
References AK_Assign, findCompleteObject(), and modifySubobject().
Referenced by HandleFunctionCall().
static bool HandleBaseToDerivedCast | ( | EvalInfo & | Info, |
const CastExpr * | E, | ||
LValue & | Result | ||
) | [static] |
HandleBaseToDerivedCast - Apply the given base-to-derived cast operation on the provided lvalue, which currently refers to the base object.
Definition at line 3150 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().
static bool HandleClassZeroInitialization | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const RecordDecl * | RD, | ||
const LValue & | This, | ||
APValue & | Result | ||
) | [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 5121 of file ExprConstant.cpp.
References EvaluateInPlace(), HandleLValueDirectBase(), HandleLValueMember(), clang::Decl::isInvalidDecl(), and clang::TagDecl::isUnion().
static bool handleCompoundAssignment | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const LValue & | LVal, | ||
QualType | LValType, | ||
QualType | PromotedLValType, | ||
BinaryOperatorKind | Opcode, | ||
const APValue & | RVal | ||
) | [static] |
Perform a compound assignment of LVal <op>= RVal.
Definition at line 2854 of file ExprConstant.cpp.
References AK_Assign, findCompleteObject(), and findSubobject().
static bool HandleConstructorCall | ( | SourceLocation | CallLoc, |
const LValue & | This, | ||
ArrayRef< const Expr * > | Args, | ||
const CXXConstructorDecl * | Definition, | ||
EvalInfo & | Info, | ||
APValue & | Result | ||
) | [static] |
Evaluate a constructor call.
Definition at line 3725 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases_begin(), AttributeLangSupport::C, EvaluateArgs(), EvaluateInPlace(), EvaluateStmt(), clang::FunctionDecl::getBody(), clang::FieldDecl::getFieldIndex(), clang::CXXRecordDecl::getNumBases(), clang::CXXRecordDecl::getNumVBases(), clang::CXXMethodDecl::getParent(), clang::FieldDecl::getParent(), clang::APValue::getStructBase(), clang::APValue::getStructField(), clang::CXXBaseSpecifier::getType(), clang::APValue::getUnionField(), clang::APValue::getUnionValue(), HandleLValueDirectBase(), HandleLValueMember(), handleLValueToRValueConversion(), clang::CXXConstructorDecl::init_begin(), clang::CXXConstructorDecl::inits(), clang::FieldDecl::isBitField(), clang::CXXConstructorDecl::isCopyConstructor(), clang::FunctionDecl::isDefaulted(), clang::CXXConstructorDecl::isDelegatingConstructor(), clang::Decl::isInvalidDecl(), clang::CXXConstructorDecl::isMoveConstructor(), clang::FunctionDecl::isTrivial(), clang::APValue::isUninit(), clang::APValue::isUnion(), clang::TagDecl::isUnion(), clang::CXXBaseSpecifier::isVirtual(), clang::format::Success, and truncateBitfieldValue().
Referenced by clang::Expr::isPotentialConstantExpr().
static bool HandleConversionToBool | ( | const APValue & | Val, |
bool & | Result | ||
) | [static] |
Definition at line 1440 of file ExprConstant.cpp.
References EvalPointerValueAsBool(), clang::APValue::getComplexFloatImag(), clang::APValue::getComplexFloatReal(), clang::APValue::getComplexIntImag(), clang::APValue::getComplexIntReal(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::APValue::getKind(), clang::APValue::getMemberPointerDecl(), and Uninitialized.
Referenced by clang::Expr::EvaluateAsBooleanCondition(), and EvaluateAsBooleanCondition().
static bool handleFloatFloatBinOp | ( | EvalInfo & | Info, |
const Expr * | E, | ||
APFloat & | LHS, | ||
BinaryOperatorKind | Opcode, | ||
const APFloat & | RHS | ||
) | [static] |
Perform the given binary floating-point operation, in-place, on LHS.
Definition at line 1731 of file ExprConstant.cpp.
References clang::BO_Add, clang::BO_Div, clang::BO_Mul, and clang::BO_Sub.
static bool HandleFloatToFloatCast | ( | EvalInfo & | Info, |
const Expr * | E, | ||
QualType | SrcType, | ||
QualType | DestType, | ||
APFloat & | Result | ||
) | [static] |
Definition at line 1505 of file ExprConstant.cpp.
References HandleOverflow().
static bool HandleFloatToIntCast | ( | EvalInfo & | Info, |
const Expr * | E, | ||
QualType | SrcType, | ||
const APFloat & | Value, | ||
QualType | DestType, | ||
APSInt & | Result | ||
) | [static] |
Definition at line 1490 of file ExprConstant.cpp.
References HandleOverflow(), and clang::Type::isSignedIntegerOrEnumerationType().
static bool HandleFunctionCall | ( | SourceLocation | CallLoc, |
const FunctionDecl * | Callee, | ||
const LValue * | This, | ||
ArrayRef< const Expr * > | Args, | ||
const Stmt * | Body, | ||
EvalInfo & | Info, | ||
APValue & | Result | ||
) | [static] |
Evaluate a function call.
Definition at line 3682 of file ExprConstant.cpp.
References EvaluateArgs(), EvaluateStmt(), clang::Decl::getLocEnd(), clang::FunctionDecl::getReturnType(), handleAssignment(), handleLValueToRValueConversion(), and clang::Type::isVoidType().
Referenced by clang::Expr::isPotentialConstantExpr().
static bool handleIncDec | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const LValue & | LVal, | ||
QualType | LValType, | ||
bool | IsIncrement, | ||
APValue * | Old | ||
) | [static] |
Perform an increment or decrement on LVal.
Definition at line 3005 of file ExprConstant.cpp.
References AK_Decrement, AK_Increment, findCompleteObject(), and findSubobject().
static bool handleIntIntBinOp | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const APSInt & | LHS, | ||
BinaryOperatorKind | Opcode, | ||
APSInt | RHS, | ||
APSInt & | Result | ||
) | [static] |
Perform the given binary integer operation.
Definition at line 1632 of file ExprConstant.cpp.
References clang::BO_Add, clang::BO_And, clang::BO_Div, clang::BO_EQ, clang::BO_GE, clang::BO_GT, clang::BO_LE, clang::BO_LT, clang::BO_Mul, clang::BO_NE, clang::BO_Or, clang::BO_Rem, clang::BO_Shl, clang::BO_Shr, clang::BO_Sub, clang::BO_Xor, CheckedIntArithmetic(), clang::Expr::getType(), and HandleOverflow().
static bool HandleIntToFloatCast | ( | EvalInfo & | Info, |
const Expr * | E, | ||
QualType | SrcType, | ||
const APSInt & | Value, | ||
QualType | DestType, | ||
APFloat & | Result | ||
) | [static] |
Definition at line 1529 of file ExprConstant.cpp.
References HandleOverflow().
static APSInt HandleIntToIntCast | ( | EvalInfo & | Info, |
const Expr * | E, | ||
QualType | DestType, | ||
QualType | SrcType, | ||
APSInt & | Value | ||
) | [static] |
Definition at line 1517 of file ExprConstant.cpp.
References clang::Type::isUnsignedIntegerOrEnumerationType().
static bool HandleLValueArrayAdjustment | ( | EvalInfo & | Info, |
const Expr * | E, | ||
LValue & | LVal, | ||
QualType | EltTy, | ||
int64_t | Adjustment | ||
) | [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 1893 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), and HandleSizeof().
static bool HandleLValueBase | ( | EvalInfo & | Info, |
const Expr * | E, | ||
LValue & | Obj, | ||
const CXXRecordDecl * | DerivedDecl, | ||
const CXXBaseSpecifier * | Base | ||
) | [static] |
Definition at line 1802 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 bool HandleLValueBasePath | ( | EvalInfo & | Info, |
const CastExpr * | E, | ||
QualType | Type, | ||
LValue & | Result | ||
) | [static] |
Definition at line 1827 of file ExprConstant.cpp.
References clang::Type::getAsCXXRecordDecl(), HandleLValueBase(), clang::CastExpr::path_begin(), and clang::CastExpr::path_end().
static bool HandleLValueComplexElement | ( | EvalInfo & | Info, |
const Expr * | E, | ||
LValue & | LVal, | ||
QualType | EltTy, | ||
bool | Imag | ||
) | [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 1911 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), and HandleSizeof().
static bool HandleLValueDirectBase | ( | EvalInfo & | Info, |
const Expr * | E, | ||
LValue & | Obj, | ||
const CXXRecordDecl * | Derived, | ||
const CXXRecordDecl * | Base, | ||
const ASTRecordLayout * | RL = nullptr |
||
) | [static] |
Definition at line 1788 of file ExprConstant.cpp.
References clang::Decl::isInvalidDecl().
Referenced by HandleClassZeroInitialization(), HandleConstructorCall(), HandleLValueBase(), and HandleMemberPointerAccess().
static bool HandleLValueIndirectMember | ( | EvalInfo & | Info, |
const Expr * | E, | ||
LValue & | LVal, | ||
const IndirectFieldDecl * | IFD | ||
) | [static] |
Update LVal to refer to the given indirect field.
Definition at line 1857 of file ExprConstant.cpp.
References AttributeLangSupport::C, clang::IndirectFieldDecl::chain(), and HandleLValueMember().
Referenced by HandleMemberPointerAccess().
static bool HandleLValueMember | ( | EvalInfo & | Info, |
const Expr * | E, | ||
LValue & | LVal, | ||
const FieldDecl * | FD, | ||
const ASTRecordLayout * | RL = nullptr |
||
) | [static] |
Update LVal to refer to the given field, which must be a member of the type currently described by LVal.
Definition at line 1842 of file ExprConstant.cpp.
References clang::FieldDecl::getFieldIndex(), clang::FieldDecl::getParent(), and clang::Decl::isInvalidDecl().
Referenced by HandleClassZeroInitialization(), HandleConstructorCall(), HandleLValueIndirectMember(), and HandleMemberPointerAccess().
static bool handleLValueToRValueConversion | ( | EvalInfo & | Info, |
const Expr * | Conv, | ||
QualType | Type, | ||
const LValue & | LVal, | ||
APValue & | RVal | ||
) | [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 2696 of file ExprConstant.cpp.
References AK_Read, Evaluate(), extractSubobject(), findCompleteObject(), clang::Expr::getType(), and clang::QualType::isVolatileQualified().
Referenced by EvaluateAsRValue(), HandleConstructorCall(), and HandleFunctionCall().
static const ValueDecl* HandleMemberPointerAccess | ( | EvalInfo & | Info, |
QualType | LVType, | ||
LValue & | LV, | ||
const Expr * | RHS, | ||
bool | IncludeMember = true |
||
) | [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 3048 of file ExprConstant.cpp.
References clang::CodeGen::Base, CastToDerivedClass(), EvaluateMemberPointer(), clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::CXXRecordDecl::getCanonicalDecl(), clang::Type::getPointeeType(), HandleLValueDirectBase(), HandleLValueIndirectMember(), and HandleLValueMember().
Referenced by HandleMemberPointerAccess().
static const ValueDecl* HandleMemberPointerAccess | ( | EvalInfo & | Info, |
const BinaryOperator * | BO, | ||
LValue & | LV, | ||
bool | IncludeMember = true |
||
) | [static] |
Definition at line 3130 of file ExprConstant.cpp.
References clang::BO_PtrMemD, clang::BO_PtrMemI, EvaluateMemberPointer(), EvaluateObjectArgument(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), and HandleMemberPointerAccess().
static void HandleOverflow | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const T & | SrcValue, | ||
QualType | DestType | ||
) | [static] |
Definition at line 1484 of file ExprConstant.cpp.
Referenced by CheckedIntArithmetic(), HandleFloatToFloatCast(), HandleFloatToIntCast(), handleIntIntBinOp(), and HandleIntToFloatCast().
static bool HandleSizeof | ( | EvalInfo & | Info, |
SourceLocation | Loc, | ||
QualType | Type, | ||
CharUnits & | Size | ||
) | [static] |
Get the size of the given type in char units.
Definition at line 1867 of file ExprConstant.cpp.
References clang::Type::isConstantSizeType(), clang::Type::isFunctionType(), and clang::Type::isVoidType().
Referenced by HandleLValueArrayAdjustment(), and HandleLValueComplexElement().
static bool HasSameBase | ( | const LValue & | A, |
const LValue & | B | ||
) | [static] |
Definition at line 6444 of file ExprConstant.cpp.
References clang::Decl::getCanonicalDecl(), GetLValueBaseDecl(), and IsGlobalLValue().
static bool IsConstNonVolatile | ( | QualType | T | ) | [static] |
Definition at line 2001 of file ExprConstant.cpp.
References clang::QualType::getQualifiers(), clang::Qualifiers::hasConst(), and clang::Qualifiers::hasVolatile().
Referenced by CheckICE().
static bool IsGlobalLValue | ( | APValue::LValueBase | B | ) | [static] |
Definition at line 1177 of file ExprConstant.cpp.
References clang::Stmt::getStmtClass(), clang::CompoundLiteralExpr::isFileScope(), clang::Expr::isLValue(), IsStringLiteralCall(), and clang::SD_Static.
Referenced by CheckLValueConstantExpression(), HasSameBase(), and clang::Expr::EvalResult::isGlobalLValue().
static bool IsLiteralLValue | ( | const LValue & | Value | ) | [static] |
Definition at line 1413 of file ExprConstant.cpp.
static bool isOnePastTheEndOfCompleteObject | ( | const ASTContext & | Ctx, |
const LValue & | LV | ||
) | [static] |
Determine whether this is a pointer past the end of the complete object referred to by the lvalue.
Definition at line 6466 of file ExprConstant.cpp.
References clang::ASTContext::getTypeSizeInChars().
static bool isOverflowingIntegerType | ( | ASTContext & | Ctx, |
QualType | T | ||
) | [static] |
Definition at line 2749 of file ExprConstant.cpp.
References clang::ASTContext::getIntWidth(), clang::ASTContext::IntTy, and clang::Type::isSignedIntegerType().
static bool isReadByLvalueToRvalueConversion | ( | QualType | T | ) | [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 2090 of file ExprConstant.cpp.
References clang::CXXRecordDecl::bases(), clang::Type::getAsCXXRecordDecl(), clang::Type::getBaseElementTypeUnsafe(), clang::CXXRecordDecl::isEmpty(), and clang::TagDecl::isUnion().
Referenced by diagnoseUnreadableFields().
static bool IsStringLiteralCall | ( | const CallExpr * | E | ) | [static] |
Should this call expression be treated as a string literal?
Definition at line 1171 of file ExprConstant.cpp.
References clang::CallExpr::getBuiltinCallee().
Referenced by IsGlobalLValue().
static bool IsWeakLValue | ( | const LValue & | Value | ) | [static] |
Definition at line 1420 of file ExprConstant.cpp.
References GetLValueBaseDecl(), and clang::ValueDecl::isWeak().
static bool modifySubobject | ( | EvalInfo & | Info, |
const Expr * | E, | ||
const CompleteObject & | Obj, | ||
const SubobjectDesignator & | Sub, | ||
APValue & | NewVal | ||
) | [static] |
Update the designated sub-object of an rvalue to the given value.
Definition at line 2428 of file ExprConstant.cpp.
References findSubobject().
Referenced by handleAssignment().
static ICEDiag NoDiag | ( | ) | [static] |
Definition at line 8576 of file ExprConstant.cpp.
Referenced by CheckEvalInICE(), and CheckICE().
static void NoteLValueLocation | ( | EvalInfo & | Info, |
APValue::LValueBase | Base | ||
) | [static] |
Definition at line 1233 of file ExprConstant.cpp.
References clang::Expr::getExprLoc(), and clang::Decl::getLocation().
Referenced by CheckLValueConstantExpression(), and findCompleteObject().
static bool truncateBitfieldValue | ( | EvalInfo & | Info, |
const Expr * | E, | ||
APValue & | Value, | ||
const FieldDecl * | FD | ||
) | [static] |
Definition at line 1540 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 bool TryEvaluateBuiltinNaN | ( | const ASTContext & | Context, |
QualType | ResultTy, | ||
const Expr * | Arg, | ||
bool | SNaN, | ||
llvm::APFloat & | Result | ||
) | [static] |
Definition at line 7524 of file ExprConstant.cpp.
References clang::ASTContext::getFloatTypeSemantics(), clang::StringLiteral::getString(), and clang::Expr::IgnoreParenCasts().
static ICEDiag Worst | ( | ICEDiag | A, |
ICEDiag | B | ||
) | [static] |
Definition at line 8578 of file ExprConstant.cpp.
Referenced by CheckICE().