clang  3.9.0
Macros | Enumerations | Functions
ExprConstant.cpp File Reference
#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/TypeNodes.def"
#include "clang/AST/BuiltinTypes.def"
#include "clang/Basic/OpenCLImageTypes.def"
#include "clang/AST/StmtNodes.inc"
Include dependency graph for ExprConstant.cpp:

Go to the source code of this file.

Macros

#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 integer_type_class;
 
#define FLOATING_TYPE(ID, SINGLETON_ID)   case BuiltinType::ID: return real_type_class;
 
#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)   case BuiltinType::ID: break;
 
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   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  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)
 Evaluate an expression as an lvalue. More...
 
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. 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, APValue &Result, EvalInfo &Info)
 
static bool EvaluateAsRValue (EvalInfo &Info, const Expr *E, APValue &Result)
 EvaluateAsRValue - Try to evaluate this expression, performing an implicit lvalue-to-rvalue cast if it is an lvalue. More...
 
static bool EvaluateIgnoredValue (EvalInfo &Info, const Expr *E)
 Evaluate an expression to see if it had side-effects, and discard its result. More...
 
static int64_t getExtValue (const APSInt &Value)
 Sign- or zero-extend a value to 64 bits. More...
 
static bool IsStringLiteralCall (const CallExpr *E)
 Should this call expression be treated as a string literal? More...
 
static void NoteLValueLocation (EvalInfo &Info, APValue::LValueBase Base)
 
static bool CheckLValueConstantExpression (EvalInfo &Info, SourceLocation Loc, QualType Type, const LValue &LVal)
 Check that this reference or pointer core constant expression is a valid value for an address or reference constant expression. 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)
 Check that this core constant expression value is a valid value for a constant expression. More...
 
static const ValueDeclGetLValueBaseDecl (const LValue &LVal)
 
static bool IsLiteralLValue (const LValue &Value)
 
static bool IsWeakLValue (const LValue &Value)
 
static bool isZeroSized (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 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, int64_t Adjustment)
 Update a pointer value to model pointer arithmetic. More...
 
static bool HandleLValueComplexElement (EvalInfo &Info, const Expr *E, LValue &LVal, QualType EltTy, bool Imag)
 Update an lvalue to refer to a component of a complex number. More...
 
static bool evaluateVarDeclInit (EvalInfo &Info, const Expr *E, const VarDecl *VD, CallStackFrame *Frame, APValue *&Result)
 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 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 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 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. 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 ValueDeclHandleMemberPointerAccess (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 ValueDeclHandleMemberPointerAccess (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 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 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)
 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 int 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 ExprignorePointerCastsAndParens (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 designator (that isn't necessarily valid). More...
 
static bool tryEvaluateBuiltinObjectSize (const Expr *E, unsigned Type, EvalInfo &Info, uint64_t &Size, bool *WasError=nullptr)
 Tries to evaluate the __builtin_object_size for E. More...
 
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. More...
 
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 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...
 

Macro Definition Documentation

#define ABSTRACT_STMT (   Node)
#define BUILTIN_TYPE (   ID,
  SINGLETON_ID 
)
#define DEPENDENT_TYPE (   ID,
  BASE 
)    case Type::ID:
#define EXPR (   Node,
  Base 
)
#define FLOATING_TYPE (   ID,
  SINGLETON_ID 
)    case BuiltinType::ID: return real_type_class;
#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 integer_type_class;
#define STMT (   Node,
  Base 
)    case Expr::Node##Class:
#define TYPE (   ID,
  BASE 
)

Enumeration Type Documentation

Kinds of access we can perform on an object, for diagnostics.

Enumerator
AK_Read 
AK_Assign 
AK_Increment 
AK_Decrement 

Definition at line 2319 of file ExprConstant.cpp.

Definition at line 150 of file ExprConstant.cpp.

Definition at line 3372 of file ExprConstant.cpp.

enum ICEKind

Definition at line 9290 of file ExprConstant.cpp.

Function Documentation

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 2651 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 1929 of file ExprConstant.cpp.

References clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTRecordLayout::getVBaseClassOffset(), and I.

Referenced by HandleBaseToDerivedCast(), HandleLValueBase(), and HandleMemberPointerAccess().

static bool CheckConstantExpression ( EvalInfo &  Info,
SourceLocation  DiagLoc,
QualType  Type,
const APValue Value 
)
static
static bool CheckConstexprFunction ( EvalInfo &  Info,
SourceLocation  CallLoc,
const FunctionDecl Declaration,
const FunctionDecl Definition,
const Stmt Body 
)
static

CheckConstexprFunction - Check that a function can be called in a constant expression.

Definition at line 3840 of file ExprConstant.cpp.

References bool, clang::InheritedConstructor::getConstructor(), clang::CXXConstructorDecl::getInheritedConstructor(), and clang::FunctionDecl::isConstexpr().

template<typename Operation >
static bool CheckedIntArithmetic ( EvalInfo &  Info,
const Expr E,
const APSInt &  LHS,
const APSInt &  RHS,
unsigned  BitWidth,
Operation  Op,
APSInt &  Result 
)
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 1778 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
static ICEDiag CheckICE ( const Expr E,
const ASTContext Ctx 
)
static
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 1478 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 1400 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 3815 of file ExprConstant.cpp.

References 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 1271 of file ExprConstant.cpp.

References E, clang::ValueDecl::getType(), I, and clang::APValue::printPretty().

static bool diagnoseUnreadableFields ( EvalInfo &  Info,
const Expr E,
QualType  T 
)
static
static bool EvalAndBitcastToAPInt ( EvalInfo &  Info,
const Expr E,
llvm::APInt &  Res 
)
static
static bool EvalPointerValueAsBool ( const APValue Value,
bool Result 
)
static
static bool Evaluate ( APValue Result,
EvalInfo &  Info,
const Expr E 
)
static
static bool EvaluateArgs ( ArrayRef< const Expr * >  Args,
ArgVector &  ArgValues,
EvalInfo &  Info 
)
static

EvaluateArgs - Evaluate the arguments to a function call.

Definition at line 3909 of file ExprConstant.cpp.

References E, Evaluate(), and I.

Referenced by HandleConstructorCall(), HandleFunctionCall(), and clang::Expr::isPotentialConstantExprUnevaluated().

static bool EvaluateArray ( const Expr E,
const LValue &  This,
APValue Result,
EvalInfo &  Info 
)
static
static bool EvaluateAsBooleanCondition ( const Expr E,
bool Result,
EvalInfo &  Info 
)
static

Definition at line 1639 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 9078 of file ExprConstant.cpp.

References CheckConstantExpression(), CheckLiteralType(), Evaluate(), clang::Expr::getExprLoc(), clang::Expr::getType(), handleLValueToRValueConversion(), clang::Expr::isGLValue(), and clang::QualType::isNull().

Referenced by clang::Expr::EvaluateAsRValue(), and tryEvaluateBuiltinObjectSize().

static bool EvaluateAtomic ( const Expr E,
APValue Result,
EvalInfo &  Info 
)
static

Definition at line 8933 of file ExprConstant.cpp.

References clang::Expr::getType(), clang::Type::isAtomicType(), and clang::Expr::isRValue().

Referenced by Evaluate().

static int EvaluateBuiltinClassifyType ( const CallExpr E,
const LangOptions LangOpts 
)
static
static bool EvaluateBuiltinConstantP ( ASTContext Ctx,
const Expr Arg 
)
static
template<typename LValue >
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 6502 of file ExprConstant.cpp.

References E.

Referenced by EvaluateBuiltinConstantP().

static bool EvaluateComplex ( const Expr E,
ComplexValue &  Res,
EvalInfo &  Info 
)
static
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 3421 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
static bool EvaluateDecl ( EvalInfo &  Info,
const Decl D 
)
static
static bool EvaluateFloat ( const Expr E,
APFloat &  Result,
EvalInfo &  Info 
)
static
static bool EvaluateIgnoredValue ( EvalInfo &  Info,
const Expr E 
)
static

Evaluate an expression to see if it had side-effects, and discard its result.

Returns
true if the caller should keep evaluating.

Definition at line 1309 of file ExprConstant.cpp.

References Evaluate().

Referenced by EvaluateStmt().

static bool EvaluateInPlace ( APValue Result,
EvalInfo &  Info,
const LValue &  This,
const Expr E,
bool  AllowNonLiteralTypes 
)
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 9056 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(), EvaluateStmt(), HandleClassZeroInitialization(), and HandleConstructorCall().

static bool EvaluateInteger ( const Expr E,
APSInt &  Result,
EvalInfo &  Info 
)
static
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 6307 of file ExprConstant.cpp.

References clang::Expr::getType(), clang::Type::isIntegralOrEnumerationType(), and clang::Expr::isRValue().

Referenced by EvaluateInteger().

static EvalStmtResult EvaluateLoopBody ( StmtResult &  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 3445 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 three cases:

  • function designators in C, and
  • "extern void" objects
  • () expressions in Objective-C

Definition at line 4762 of file ExprConstant.cpp.

References E, 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
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 3207 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
static bool EvaluateRecord ( const Expr E,
const LValue &  This,
APValue Result,
EvalInfo &  Info 
)
static
static EvalStmtResult EvaluateStmt ( StmtResult &  Result,
EvalInfo &  Info,
const Stmt S,
const SwitchCase SC = nullptr 
)
static
static EvalStmtResult EvaluateSwitch ( StmtResult &  Result,
EvalInfo &  Info,
const SwitchStmt SS 
)
static
static bool EvaluateTemporary ( const Expr E,
LValue &  Result,
EvalInfo &  Info 
)
static

Evaluate an expression of record type as a temporary.

Definition at line 5805 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.

Parameters
InfoInformation about the ongoing evaluation.
EAn expression to be used when printing diagnostics.
VDThe variable whose initializer should be obtained.
FrameThe frame in which the variable was created. Must be null if this variable is not local to the evaluation.
ResultFilled in with a pointer to the value of the variable.

Definition at line 2107 of file ExprConstant.cpp.

References clang::VarDecl::checkInitIsICE(), clang::VarDecl::evaluateValue(), clang::VarDecl::getAnyInitializer(), clang::VarDecl::getEvaluatedValue(), clang::Expr::isValueDependent(), and clang::ValueDecl::isWeak().

Referenced by findCompleteObject().

static bool EvaluateVector ( const Expr E,
APValue Result,
EvalInfo &  Info 
)
static

Definition at line 5847 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 8974 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
static void expandStringLiteral ( EvalInfo &  Info,
const Expr Lit,
APValue Result 
)
static
static APSInt extractStringLiteralCharacter ( EvalInfo &  Info,
const Expr Lit,
uint64_t  Index 
)
static
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 2545 of file ExprConstant.cpp.

References findSubobject().

Referenced by handleLValueToRValueConversion().

static bool FastEvaluateAsRValue ( const Expr Exp,
Expr::EvalResult Result,
const ASTContext Ctx,
bool IsConst 
)
static
static CompleteObject findCompleteObject ( EvalInfo &  Info,
const Expr E,
AccessKinds  AK,
const LValue &  LVal,
QualType  LValType 
)
static
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 2615 of file ExprConstant.cpp.

References clang::Type::castAs(), clang::Type::castAsArrayTypeUnsafe(), clang::ComplexType::getElementType(), clang::ArrayType::getElementType(), I, clang::Type::isAnyComplexType(), clang::Type::isArrayType(), clang::QualType::isNull(), and min().

Referenced by AreElementsOfSameArray().

template<typename SubobjectHandler >
SubobjectHandler::result_type findSubobject ( EvalInfo &  Info,
const Expr E,
const CompleteObject &  Obj,
const SubobjectDesignator &  Sub,
SubobjectHandler &  handler 
)
static CharUnits GetAlignOfExpr ( EvalInfo &  Info,
const Expr E 
)
static
static CharUnits GetAlignOfType ( EvalInfo &  Info,
QualType  T 
)
static
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 2183 of file ExprConstant.cpp.

References clang::CXXRecordDecl::bases_begin(), clang::CXXRecordDecl::bases_end(), E, clang::CXXRecordDecl::getCanonicalDecl(), and I.

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 1319 of file ExprConstant.cpp.

static const ValueDecl* GetLValueBaseDecl ( const LValue &  LVal)
static

Definition at line 1563 of file ExprConstant.cpp.

Referenced by HasSameBase(), IsWeakLValue(), and isZeroSized().

static QualType getObjectType ( APValue::LValueBase  B)
static
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 2920 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 3335 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 5434 of file ExprConstant.cpp.

References distance(), End, EvaluateInPlace(), clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::RecordDecl::fields(), HandleLValueDirectBase(), HandleLValueMember(), I, 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 3039 of file ExprConstant.cpp.

References AK_Assign, E, findCompleteObject(), and findSubobject().

static bool HandleConstructorCall ( const Expr E,
const LValue &  This,
APValue ArgValues,
const CXXConstructorDecl Definition,
EvalInfo &  Info,
APValue Result 
)
static
static bool HandleConstructorCall ( const Expr E,
const LValue &  This,
ArrayRef< const Expr * >  Args,
const CXXConstructorDecl Definition,
EvalInfo &  Info,
APValue Result 
)
static

Definition at line 4117 of file ExprConstant.cpp.

References EvaluateArgs(), and HandleConstructorCall().

static bool HandleConversionToBool ( const APValue Val,
bool Result 
)
static
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 1899 of file ExprConstant.cpp.

static bool HandleFloatToFloatCast ( EvalInfo &  Info,
const Expr E,
QualType  SrcType,
QualType  DestType,
APFloat &  Result 
)
static

Definition at line 1671 of file ExprConstant.cpp.

References HandleOverflow().

static bool HandleFloatToIntCast ( EvalInfo &  Info,
const Expr E,
QualType  SrcType,
const APFloat &  Value,
QualType  DestType,
APSInt &  Result 
)
static
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 
)
static
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 3190 of file ExprConstant.cpp.

References AK_Decrement, AK_Increment, E, 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 1801 of file ExprConstant.cpp.

References 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 1695 of file ExprConstant.cpp.

References HandleOverflow().

static APSInt HandleIntToIntCast ( EvalInfo &  Info,
const Expr E,
QualType  DestType,
QualType  SrcType,
const APSInt &  Value 
)
static
static bool HandleLValueArrayAdjustment ( EvalInfo &  Info,
const Expr E,
LValue &  LVal,
QualType  EltTy,
int64_t  Adjustment 
)
static

Update a pointer value to model pointer arithmetic.

Parameters
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 2068 of file ExprConstant.cpp.

References clang::Expr::getExprLoc(), and HandleSizeof().

Referenced by tryEvaluateBuiltinObjectSize().

static bool HandleLValueBase ( EvalInfo &  Info,
const Expr E,
LValue &  Obj,
const CXXRecordDecl DerivedDecl,
const CXXBaseSpecifier Base 
)
static
static bool HandleLValueBasePath ( EvalInfo &  Info,
const CastExpr E,
QualType  Type,
LValue &  Result 
)
static
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.

Parameters
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 2086 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
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 2027 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 2012 of file ExprConstant.cpp.

References clang::FieldDecl::getFieldIndex(), and clang::FieldDecl::getParent().

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.

Parameters
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 2882 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.

Parameters
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.
Returns
The field or method declaration to which the member pointer refers, or 0 if evaluation fails.

Definition at line 3233 of file ExprConstant.cpp.

References CastToDerivedClass(), EvaluateMemberPointer(), clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::CXXRecordDecl::getCanonicalDecl(), clang::Type::getPointeeType(), HandleLValueDirectBase(), HandleLValueIndirectMember(), HandleLValueMember(), and I.

Referenced by HandleMemberPointerAccess().

static const ValueDecl* HandleMemberPointerAccess ( EvalInfo &  Info,
const BinaryOperator BO,
LValue &  LV,
bool  IncludeMember = true 
)
static
template<typename T >
static bool HandleOverflow ( EvalInfo &  Info,
const Expr E,
const T &  SrcValue,
QualType  DestType 
)
static
static bool HandleSizeof ( EvalInfo &  Info,
SourceLocation  Loc,
QualType  Type,
CharUnits Size 
)
static
static bool hasFields ( const CXXRecordDecl RD)
static

Determine if a class has any fields that might need to be copied by a trivial copy or move operation.

Definition at line 3890 of file ExprConstant.cpp.

References clang::CXXRecordDecl::bases(), clang::RecordDecl::fields(), and clang::CXXRecordDecl::isEmpty().

Referenced by HandleConstructorCall(), and HandleFunctionCall().

static bool HasSameBase ( const LValue &  A,
const LValue &  B 
)
static

Definition at line 7089 of file ExprConstant.cpp.

References GetLValueBaseDecl(), and IsGlobalLValue().

static bool hasUnacceptableSideEffect ( Expr::EvalStatus Result,
Expr::SideEffectsKind  SEK 
)
static
static const Expr* ignorePointerCastsAndParens ( const Expr E)
static

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 6571 of file ExprConstant.cpp.

References clang::CastExpr::getCastKind(), clang::Expr::getType(), clang::Type::hasPointerRepresentation(), clang::Expr::IgnoreParens(), and clang::Expr::isRValue().

Referenced by tryEvaluateBuiltinObjectSize().

static bool IsConstNonVolatile ( QualType  T)
static
static bool isDesignatorAtObjectEnd ( const ASTContext Ctx,
const LValue &  LVal 
)
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, it will always return true.

Definition at line 6606 of file ExprConstant.cpp.

References clang::Type::castAs(), E, clang::ASTContext::getAsArrayType(), clang::ASTContext::getASTRecordLayout(), clang::ComplexType::getElementType(), clang::ArrayType::getElementType(), clang::ASTRecordLayout::getFieldCount(), clang::FieldDecl::getFieldIndex(), clang::FieldDecl::getParent(), clang::ConstantArrayType::getSize(), clang::ValueDecl::getType(), I, clang::Type::isAnyComplexType(), clang::Type::isArrayType(), and clang::TagDecl::isUnion().

Referenced by tryEvaluateBuiltinObjectSize().

static bool IsGlobalLValue ( APValue::LValueBase  B)
static
static bool IsLiteralLValue ( const LValue &  Value)
static

Definition at line 1567 of file ExprConstant.cpp.

References E.

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 7111 of file ExprConstant.cpp.

References clang::ASTContext::getTypeSizeInChars(), and clang::Type::isIncompleteType().

static bool isOverflowingIntegerType ( ASTContext Ctx,
QualType  T 
)
static
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 2265 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().

static bool IsStringLiteralCall ( const CallExpr E)
static

Should this call expression be treated as a string literal?

Definition at line 1325 of file ExprConstant.cpp.

References clang::CallExpr::getBuiltinCallee().

Referenced by IsGlobalLValue().

static bool IsWeakLValue ( const LValue &  Value)
static

Definition at line 1574 of file ExprConstant.cpp.

References GetLValueBaseDecl(), and clang::ValueDecl::isWeak().

static bool isZeroSized ( const LValue &  Value)
static
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 2605 of file ExprConstant.cpp.

References findSubobject().

Referenced by handleAssignment().

static ICEDiag NoDiag ( )
static

Definition at line 9310 of file ExprConstant.cpp.

Referenced by CheckEvalInICE(), and CheckICE().

static void NoteLValueLocation ( EvalInfo &  Info,
APValue::LValueBase  Base 
)
static

Definition at line 1387 of file ExprConstant.cpp.

References clang::Expr::getExprLoc().

Referenced by CheckLValueConstantExpression(), and findCompleteObject().

static bool refersToCompleteObject ( const LValue &  LVal)
static

Tests to see if the LValue has a designator (that isn't necessarily valid).

Definition at line 6666 of file ExprConstant.cpp.

Referenced by tryEvaluateBuiltinObjectSize().

static bool truncateBitfieldValue ( EvalInfo &  Info,
const Expr E,
APValue Value,
const FieldDecl FD 
)
static
static bool TryEvaluateBuiltinNaN ( const ASTContext Context,
QualType  ResultTy,
const Expr Arg,
bool  SNaN,
llvm::APFloat &  Result 
)
static
static bool tryEvaluateBuiltinObjectSize ( const Expr E,
unsigned  Type,
EvalInfo &  Info,
uint64_t &  Size,
bool WasError = nullptr 
)
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 6684 of file ExprConstant.cpp.

References E, End, clang::serialized_diags::Error, EvaluateAsRValue(), EvaluatePointer(), getObjectType(), HandleLValueArrayAdjustment(), ignorePointerCastsAndParens(), isDesignatorAtObjectEnd(), clang::Type::isFunctionType(), clang::Expr::isGLValue(), clang::Type::isIncompleteType(), clang::CharUnits::isNegative(), clang::QualType::isNull(), refersToCompleteObject(), and S.

Referenced by clang::Expr::tryEvaluateObjectSize().

static ICEDiag Worst ( ICEDiag  A,
ICEDiag  B 
)
static

Definition at line 9312 of file ExprConstant.cpp.

Referenced by CheckICE().