Go to the documentation of this file.
14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H
15 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H
30 #include "llvm/ADT/ImmutableList.h"
31 #include "llvm/ADT/Optional.h"
36 class AnalyzerOptions;
38 class CXXBoolLiteralExpr;
43 class LocationContext;
44 class StackFrameContext;
49 class ConditionTruthVal;
50 class ProgramStateManager;
54 virtual void anchor();
197 const void *symbolTag =
nullptr) {
204 const void *symbolTag =
nullptr) {
232 unsigned visitCount);
264 unsigned blockCount);
370 assert((
type->isPointerType() ||
type->isObjCObjectPointerType() ||
371 type->isBlockPointerType() ||
type->isNullPtrType() ||
372 type->isReferenceType()) &&
373 "makeNullWithType must use pointer type");
424 ProgramStateManager &stateMgr);
430 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H
const std::pair< SVal, uintptr_t > & getPersistentSValWithData(const SVal &V, uintptr_t Data)
SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, SVal lhs, SVal rhs, QualType type)
static bool isLocType(QualType T)
A boolean literal, per ([C++ lex.bool] Boolean literals).
const SymbolConjured * conjureSymbol(const Stmt *E, const LocationContext *LCtx, QualType T, unsigned VisitCount, const void *SymbolTag=nullptr)
const AnalyzerOptions & getAnalyzerOptions() const
ProgramStateManager & getStateManager()
NonLoc makeLazyCompoundVal(const StoreRef &store, const TypedValueRegion *region)
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
ProgramStateManager & StateMgr
DefinedSVal getMetadataSymbolVal(const void *symbolTag, const MemRegion *region, const Expr *expr, QualType type, const LocationContext *LCtx, unsigned count)
NonLoc makePointerToMember(const PointerToMemberData *PTMD)
NonLoc makeLocAsInteger(Loc loc, unsigned bits)
SValBuilder * createSimpleSValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context, ProgramStateManager &stateMgr)
This represents a decl that may have a name.
loc::ConcreteInt makeNullWithType(QualType type)
Create NULL pointer, with proper pointer bit-width for given address space.
A (possibly-)qualified type.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(SymbolRef parentSymbol, const TypedValueRegion *region)
QualType getArrayIndexType() const
DefinedOrUnknownSVal makeZeroVal(QualType type)
Construct an SVal representing '0' for the specified type.
It represents a stack frame of the call stack (based on CallEvent).
Value representing integer constant.
const CompoundValData * getCompoundValData(QualType T, llvm::ImmutableList< SVal > Vals)
DefinedOrUnknownSVal getConjuredHeapSymbolVal(const Expr *E, const LocationContext *LCtx, unsigned Count)
Conjure a symbol representing heap allocated memory region.
A symbol representing the result of an expression in the case when we do not know anything about what...
virtual const llvm::APSInt * getKnownValue(ProgramStateRef state, SVal val)=0
Evaluates a given SVal.
DefinedSVal makeSymbolVal(SymbolRef Sym)
Make an SVal that represents the given symbol.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
MemRegion - The root abstract class for all memory regions.
NonLoc makeIntValWithWidth(QualType ptrType, uint64_t integer)
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
DefinedSVal makeIntVal(uint64_t integer, QualType type)
loc::MemRegionVal makeLoc(const MemRegion *region)
const SymbolConjured * conjureSymbol(const Stmt *stmt, const LocationContext *LCtx, QualType type, unsigned visitCount, const void *symbolTag=nullptr)
const AnalyzerOptions & AnOpts
virtual QualType getType() const =0
Represents a block literal declaration, which is like an unnamed FunctionDecl.
DefinedOrUnknownSVal getRegionValueSymbolVal(const TypedValueRegion *region)
Make a unique symbol for value of region.
ASTContext & getContext()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrameContext *SFC)
Return a memory region for the 'this' object reference.
SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context, ProgramStateManager &stateMgr)
NonLoc makeZeroArrayIndex()
SVal convertToArrayIndex(SVal val)
MemRegionManager & getRegionManager()
Value representing pointer-to-member.
const ASTContext & getContext() const
Optional< SVal > getConstantVal(const Expr *E)
Returns the value of E, if it can be determined in a non-path-sensitive manner.
BasicValueFactory & getBasicValueFactory()
loc::GotoLabel makeLoc(const AddrLabelExpr *expr)
NonLoc makePointerToMember(const DeclaratorDecl *DD)
virtual SVal simplifySVal(ProgramStateRef State, SVal Val)=0
Simplify symbolic expressions within a given SVal.
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...
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
const llvm::APSInt & getIntValue(uint64_t X, bool isUnsigned)
and static some checkers Checker The latter are built on top of the former via the Checker and CheckerVisitor and attempts to isolate them from much of the gore of the internal analysis the analyzer is basically a source code simulator that traces out possible paths of execution The state of the and the combination of state and program point is a node in an exploded which has the entry program point and initial state
Optional< loc::MemRegionVal > getCastedMemRegionVal(const MemRegion *region, QualType type)
Return MemRegionVal on success cast, otherwise return None.
llvm::APInt getValue() const
SVal makeSymExprValNN(BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)
Constructs a symbolic expression for two non-location values.
Represents a C++ struct/union/class.
NonLoc makeCompoundVal(QualType type, llvm::ImmutableList< SVal > vals)
loc::MemRegionVal makeLoc(SymbolRef sym)
SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy)
Cast a given SVal to another SVal using given QualType's.
const BasicValueFactory & getBasicValueFactory() const
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.
NonLoc makeIntVal(const llvm::APInt &integer, bool isUnsigned)
Represents a ValueDecl that came out of a declarator.
AddrLabelExpr - The GNU address of label extension, representing &&label.
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
loc::ConcreteInt makeIntLocVal(const llvm::APSInt &integer)
const SymbolManager & getSymbolManager() const
Stores options for the analyzer from the command line.
const LazyCompoundValData * getLazyCompoundValData(const StoreRef &store, const TypedValueRegion *region)
nonloc::ConcreteInt makeIntVal(const llvm::APSInt &integer)
DefinedSVal getFunctionPointer(const FunctionDecl *func)
NonLoc makeIntVal(uint64_t integer, bool isUnsigned)
const SymbolConjured * conjureSymbol(const Expr *expr, const LocationContext *LCtx, unsigned visitCount, const void *symbolTag=nullptr)
DefinedSVal getBlockPointer(const BlockDecl *block, CanQualType locTy, const LocationContext *locContext, unsigned blockCount)
const MemRegionManager & getRegionManager() const
const unsigned ArrayIndexWidth
The width of the scalar type used for array indices.
virtual SVal evalComplement(NonLoc val)=0
loc::ConcreteInt makeLoc(const llvm::APSInt &integer)
Represents symbolic expression that isn't a location.
nonloc::ConcreteInt makeTruthVal(bool b, QualType type)
ConditionTruthVal areEqual(ProgramStateRef state, SVal lhs, SVal rhs)
virtual ~SValBuilder()=default
virtual SVal evalMinus(NonLoc val)=0
Stmt - This represents one statement.
SVal evalIntegralCast(ProgramStateRef state, SVal val, QualType castTy, QualType originalType)
BasicValueFactory BasicVals
Manager of APSInt values.
SVal evalCastSubKind(loc::ConcreteInt V, QualType CastTy, QualType OriginalTy)
nonloc::ConcreteInt makeBoolVal(const ObjCBoolLiteralExpr *boolean)
nonloc::SymbolVal simplifySymbolCast(nonloc::SymbolVal V, QualType CastTy)
Reduce cast expression by removing redundant intermediate casts.
SymbolManager & getSymbolManager()
SVal evalCastKind(UndefinedVal V, QualType CastTy, QualType OriginalTy)
SymbolManager SymMgr
Manages the creation of symbols.
const QualType ArrayIndexTy
The scalar type to use for array indices.
NonLoc makeArrayIndex(uint64_t idx)
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
nonloc::SymbolVal makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType type)
TypedValueRegion - An abstract class representing regions having a typed value.
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym, const MemSpaceRegion *MemSpace=nullptr)
Retrieve or create a "symbolic" memory region.
SVal evalEQ(ProgramStateRef state, SVal lhs, SVal rhs)
This represents one expression.
nonloc::ConcreteInt makeTruthVal(bool b)
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, const Expr *expr, const LocationContext *LCtx, unsigned count)
Create a new symbol with a unique 'name'.
QualType getConditionType() const
DefinedSVal getMemberPointer(const NamedDecl *ND)
Represents a function declaration or definition.
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.
const llvm::APSInt & getZeroWithTypeSize(QualType T)
const LangOptions & getLangOpts() const
Represents a static or instance method of a struct/union/class.
MemRegionManager MemMgr
Manages the creation of memory regions.
const llvm::APSInt & getTruthValue(bool b, QualType T)