23 using namespace clang;
30 void SValBuilder::anchor() { }
82 const llvm::APSInt&
I = CI->getValue();
153 unsigned visitCount) {
171 unsigned VisitCount) {
223 unsigned blockCount) {
249 switch (E->getStmtClass()) {
252 case Stmt::AddrLabelExprClass:
253 return makeLoc(cast<AddrLabelExpr>(E));
255 case Stmt::CXXScalarValueInitExprClass:
256 case Stmt::ImplicitValueInitExprClass:
259 case Stmt::ObjCStringLiteralClass: {
264 case Stmt::StringLiteralClass: {
271 case Stmt::CharacterLiteralClass: {
276 case Stmt::CXXBoolLiteralExprClass:
279 case Stmt::TypeTraitExprClass: {
284 case Stmt::IntegerLiteralClass:
287 case Stmt::ObjCBoolLiteralExprClass:
290 case Stmt::CXXNullPtrLiteralExprClass:
293 case Stmt::ImplicitCastExprClass: {
298 case CK_ArrayToPointerDecay:
336 if (!State->isTainted(RHS) && !State->isTainted(LHS))
343 const unsigned MaxComp = 10000;
345 if (symLHS && symRHS &&
347 return makeNonLoc(symLHS, Op, symRHS, ResultTy);
351 return makeNonLoc(symLHS, Op, rInt->getValue(), ResultTy);
355 return makeNonLoc(lInt->getValue(), Op, symRHS, ResultTy);
385 assert(op == BO_Add);
416 if (Quals1 != Quals2)
439 return evalCast(val, castTy, originalTy);
443 return evalCast(val, castTy, originalTy);
450 makeIntVal(ToTypeMax.isUnsigned() ? ToTypeMax.getZExtValue()
451 : ToTypeMax.getSExtValue(),
461 std::tie(IsNotTruncated, IsTruncated) = state->assume(CompVal);
462 if (!IsNotTruncated && IsTruncated) {
467 return evalCast(val, castTy, originalTy);
490 return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
513 if (
const MemRegion *R = LV->getLoc().getAsRegion()) {
533 QualType elemTy = arrayT->getElementType();
const SymExpr * getAsSymExpr() const
CastKind getCastKind() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
TypedValueRegion - An abstract class representing regions having a typed value.
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
bool isNullPtrType() const
DefinedSVal getBlockPointer(const BlockDecl *block, CanQualType locTy, const LocationContext *locContext, unsigned blockCount)
ASTContext & getASTContext() const
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
bool isMemberPointerType() const
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
const IntSymExpr * getIntSymExpr(const llvm::APSInt &lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
BlockCodeRegion - A region that represents code texts of blocks (closures).
virtual QualType getValueType() const =0
SVal makeSymExprValNN(ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)
Constructs a symbolic expression for two non-location values.
ProgramStateManager & StateMgr
The base class of the type hierarchy.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
bool isBooleanType() const
bool isBlockPointerType() const
SVal evalCast(SVal val, QualType castTy, QualType originalType)
Value representing integer constant.
MemRegionManager MemMgr
Manages the creation of memory regions.
virtual SVal dispatchCast(SVal val, QualType castTy)=0
loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrameContext *SFC)
Return a memory region for the 'this' object reference.
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType type)
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
unsigned getValue() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
bool isZeroConstant() const
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
const MemRegion * castRegion(const MemRegion *region, QualType CastToTy)
castRegion - Used by ExprEngine::VisitCast to handle casts from a MemRegion* to a specific location t...
const SymbolDerived * getDerivedSymbol(SymbolRef parentSymbol, const TypedValueRegion *R)
virtual SVal evalCastFromNonLoc(NonLoc val, QualType castTy)=0
virtual SVal evalBinOpLN(ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, NonLoc rhs, QualType resultTy)=0
Create a new value which represents a binary expression with a memory location and non-location opera...
MemRegionManager & getRegionManager()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned computeComplexity() const
SVal evalIntegralCast(ProgramStateRef state, SVal val, QualType castTy, QualType originalType)
bool isReferenceType() const
static bool canSymbolicate(QualType T)
AnalysisDeclContext * getAnalysisDeclContext() const
DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(SymbolRef parentSymbol, const TypedValueRegion *region)
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym)
Retrieve or create a "symbolic" memory region.
static bool isLocType(QualType T)
BlockDataRegion - A region that represents a block instance.
bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2)
UnwrapSimilarPointerTypes - If T1 and T2 are pointer types that may be similar (C++ 4...
bool isUnknownOrUndef() const
const SymIntExpr * getSymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
DefinedOrUnknownSVal getRegionValueSymbolVal(const TypedValueRegion *region)
Make a unique symbol for value of region.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
A record of the "type" of an APSInt, used for conversions.
ObjCStringLiteral, used for Objective-C string literals i.e.
DefinedSVal getFunctionPointer(const FunctionDecl *func)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
detail::InMemoryDirectory::const_iterator I
const BlockCodeRegion * getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
nonloc::ConcreteInt makeBoolVal(const ObjCBoolLiteralExpr *boolean)
Loc makeLoc(SymbolRef sym)
bool isFunctionPointerType() const
DefinedOrUnknownSVal makeZeroVal(QualType type)
Construct an SVal representing '0' for the specified type.
const Type * getTypeForDecl() const
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Expr - This represents one expression.
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
bool isVariableArrayType() const
const QualType ArrayIndexTy
The scalar type to use for array indices.
virtual SVal evalBinOpLL(ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, Loc rhs, QualType resultTy)=0
Create a new value which represents a binary expression with two memory location operands.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, SVal lhs, SVal rhs, QualType type)
StoreManager & getStoreManager()
The result type of a method or function.
QualType getConditionType() const
void removeCVRQualifiers(unsigned mask)
const SymbolCast * getCastSymbol(const SymExpr *Operand, QualType From, QualType To)
llvm::APSInt getMaxValue() const LLVM_READONLY
Returns the maximum value for this type.
const SymSymExpr * getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
SymbolManager SymMgr
Manages the creation of symbols.
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, const Expr *expr, const LocationContext *LCtx, unsigned count)
Create a new symbol with a unique 'name'.
virtual SVal evalCastFromLoc(Loc val, QualType castTy)=0
Represents a static or instance method of a struct/union/class.
ASTContext & getContext()
const SymbolRegionValue * getRegionValueSymbol(const TypedValueRegion *R)
Make a unique symbol for MemRegion R according to its kind.
const SymbolMetadata * getMetadataSymbol(const MemRegion *R, const Stmt *S, QualType T, unsigned VisitCount, const void *SymbolTag=nullptr)
Creates a metadata symbol associated with a specific region.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
static bool shouldBeModeledWithNoOp(ASTContext &Context, QualType ToTy, QualType FromTy)
Recursively check if the pointer types are equal modulo const, volatile, and restrict qualifiers...
DefinedOrUnknownSVal getConjuredHeapSymbolVal(const Expr *E, const LocationContext *LCtx, unsigned Count)
Conjure a symbol representing heap allocated memory region.
virtual SVal evalBinOpNN(ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)=0
Create a new value which represents a binary expression with two non- location operands.
const unsigned ArrayIndexWidth
The width of the scalar type used for array indices.
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
SVal ArrayToPointer(Loc Array, QualType ElementTy)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DefinedSVal getMetadataSymbolVal(const void *symbolTag, const MemRegion *region, const Expr *expr, QualType type, unsigned count)
Represents symbolic expression.
detail::InMemoryDirectory::const_iterator E
const MemRegion * getAsRegion() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
SVal convertToArrayIndex(SVal val)
const SymbolConjured * conjureSymbol(const Stmt *E, const LocationContext *LCtx, QualType T, unsigned VisitCount, const void *SymbolTag=nullptr)
const FunctionCodeRegion * getFunctionCodeRegion(const NamedDecl *FD)
BasicValueFactory & getBasicValueFactory()
QualType getCanonicalType() const
bool isFunctionType() const
const BlockDataRegion * getBlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount)
getBlockDataRegion - Get the memory region associated with an instance of a block.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
DefinedOrUnknownSVal evalEQ(ProgramStateRef state, DefinedOrUnknownSVal lhs, DefinedOrUnknownSVal rhs)
Optional< SVal > getConstantVal(const Expr *E)
Returns the value of E, if it can be determined in a non-path-sensitive manner.
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
StringLiteral - This represents a string literal expression, e.g.
const SymExpr * getAsSymbolicExpression() const
getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression...
nonloc::ConcreteInt makeTruthVal(bool b, QualType type)
A boolean literal, per ([C++ lex.bool] Boolean literals).
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
bool isPointerType() const