15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
22 #include "llvm/ADT/FoldingSet.h"
23 #include "llvm/ADT/ImmutableList.h"
33 class CompoundValData;
34 class LazyCompoundValData;
35 class PointerToMemberData;
37 class BasicValueFactory;
39 class TypedValueRegion;
40 class MemRegionManager;
41 class ProgramStateManager;
47 #define NONLOC_SVAL(Id, Parent) Id ## Kind,
48 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
55 #define LOC_SVAL(Id, Parent) Id ## Kind,
56 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
67 #define BASIC_SVAL(Id, Parent) Id ## Kind,
68 #define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
69 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
80 explicit SVal(
const void *d,
bool isLoc,
unsigned ValKind)
93 assert(T::isKind(*
this));
94 return *
static_cast<const T *
>(
this);
101 if (!T::isKind(*
this))
103 return *
static_cast<const T *
>(
this);
125 return !(*
this == R);
208 static bool isKind(
const SVal& V) {
217 bool isUndef()
const =
delete;
218 bool isValid()
const =
delete;
223 :
SVal(d, isLoc, ValKind) {}
230 static bool isKind(
const SVal& V) {
241 static bool isKind(
const SVal &V) {
250 bool isUnknown()
const =
delete;
251 bool isUnknownOrUndef()
const =
delete;
252 bool isValid()
const =
delete;
259 static bool isKind(
const SVal& V) {
269 static bool isKind(
const SVal &V) {
280 explicit NonLoc(
unsigned SubKind,
const void *d)
293 static bool isKind(
const SVal& V) {
301 explicit Loc(
unsigned SubKind,
const void *D)
314 static bool isKind(
const SVal& V) {
341 static bool isKind(
const SVal& V) {
346 static bool isKind(
const NonLoc& V) {
357 return *
static_cast<const llvm::APSInt*
>(
Data);
371 static bool isKind(
const SVal& V) {
376 static bool isKind(
const NonLoc& V) {
384 explicit LocAsInteger(
const std::pair<SVal, uintptr_t> &data)
385 :
NonLoc(LocAsIntegerKind, &data) {
388 assert(data.first.getBaseKind() == LocKind &&
389 (data.first.getSubKind() == loc::MemRegionValKind ||
390 data.first.getSubKind() == loc::GotoLabelKind));
396 const std::pair<SVal, uintptr_t> *D =
397 static_cast<const std::pair<SVal, uintptr_t> *
>(
Data);
402 const std::pair<SVal, uintptr_t> *D =
403 static_cast<const std::pair<SVal, uintptr_t> *
>(
Data);
404 const SVal& V = D->first;
409 const std::pair<SVal, uintptr_t> *D =
410 static_cast<const std::pair<SVal, uintptr_t> *
>(
Data);
417 static bool isKind(
const SVal& V) {
422 static bool isKind(
const NonLoc& V) {
444 static bool isKind(
const SVal& V) {
448 static bool isKind(
const NonLoc& V) {
457 :
NonLoc(LazyCompoundValKind, D) {}
468 static bool isKind(
const SVal& V) {
472 static bool isKind(
const NonLoc& V) {
493 return PTMDataType::getFromOpaqueValue(const_cast<void *>(
Data));
499 template<
typename AdjustedDecl>
501 return dyn_cast_or_null<AdjustedDecl>(
getDecl());
509 :
NonLoc(PointerToMemberKind, D.getOpaqueValue()) {}
512 static bool isKind(
const SVal& V) {
517 static bool isKind(
const NonLoc& V) {
543 static bool isKind(
const SVal& V) {
547 static bool isKind(
const Loc& V) {
567 template <
typename REGION>
583 static bool isKind(
const SVal& V) {
588 static bool isKind(
const Loc& V) {
598 return *
static_cast<const llvm::APSInt*
>(
Data);
608 static bool isKind(
const SVal& V) {
613 static bool isKind(
const Loc& V) {
631 template <
typename T>
struct isPodLike;
633 static const bool value =
true;
KnownSVal(const UndefinedVal &V)
void Profile(llvm::FoldingSetNodeID &ID) const
const SymExpr * getAsSymExpr() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
TypedValueRegion - An abstract class representing regions having a typed value.
bool hasConjuredSymbol() const
hasConjuredSymbol - If this SVal wraps a conjured symbol, return true;
bool isNullPtrType() const
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
SVal(BaseKind k, const void *D=nullptr)
bool operator==(const SVal &R) const
const MemRegion * stripCasts(bool StripBaseCasts=true) const
Get the underlining region and strip casts.
bool operator==(const MemRegionVal &R) const
DefinedOrUnknownSVal(const void *d, bool isLoc, unsigned ValKind)
bool isRecordType() const
SVal(const void *d, bool isLoc, unsigned ValKind)
void dumpToStream(raw_ostream &Out) const
SymbolRef getLocSymbolInBase() const
Get the symbol in the SVal or its base region.
Loc(unsigned SubKind, const void *D)
bool isBlockPointerType() const
Value representing integer constant.
GotoLabel(const LabelDecl *Label)
Kind
Sub-kinds for NonLoc values.
bool isZeroConstant() const
Loc getPersistentLoc() const
bool operator!=(const SVal &R) const
Value representing pointer-to-member.
bool isReferenceType() const
bool isAnyPointerType() const
BaseKind getBaseKind() const
ConcreteInt(const llvm::APSInt &V)
SymbolRef getAsLocSymbol(bool IncludeBaseRegions=false) const
If this SVal is a location and wraps a symbol, return that SymbolRef.
llvm::ImmutableList< const CXXBaseSpecifier * >::iterator iterator
SVal evalBinOp(BasicValueFactory &BasicVals, BinaryOperator::Opcode Op, const ConcreteInt &R) const
const FunctionDecl * getAsFunctionDecl() const
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl...
static bool isCompoundType(QualType T)
static bool isLocType(QualType T)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool isUnknownOrUndef() const
SymExpr::symbol_iterator symbol_begin() const
const CompoundValData * getValue() const
#define REGION(Id, Parent)
unsigned getNumBits() const
detail::InMemoryDirectory::const_iterator I
KnownSVal(const DefinedSVal &V)
llvm::ImmutableList< SVal >::iterator iterator
Represents a ValueDecl that came out of a declarator.
unsigned getRawKind() const
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
llvm::PointerUnion< const DeclaratorDecl *, const PointerToMemberData * > PTMDataType
MemRegionVal(const MemRegion *r)
unsigned Kind
The lowest 2 bits are a BaseKind (0 – 3).
const DeclaratorDecl * getDecl() const
const LazyCompoundValData * getCVData() const
NonLoc(unsigned SubKind, const void *d)
SVal evalBinOp(SValBuilder &svalBuilder, BinaryOperator::Opcode Op, const ConcreteInt &R) const
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
const REGION * getRegionAs() const
LabelDecl - Represents the declaration of a label.
void dumpToStream(raw_ostream &Out) const
SymExpr::symbol_iterator symbol_end() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
bool isNullMemberPointer() const
SymbolRef getSymbol() const
const AdjustedDecl * getDeclAs() const
ConcreteInt evalMinus(SValBuilder &svalBuilder) const
bool isVectorType() const
DefinedOrUnknownSVal(BaseKind k, void *D=nullptr)
const PTMDataType getPTMData() const
unsigned getSubKind() const
const llvm::APSInt & getValue() const
Kind
Sub-kinds for Loc values.
SmallVector< SVal, 5 > BufferTy
BufferTy - A temporary buffer to hold a set of SVals.
const LabelDecl * getLabel() const
static symbol_iterator symbol_end()
DefinedSVal(const void *d, bool isLoc, unsigned ValKind)
bool isExpression() const
Represents symbolic expression.
const MemRegion * getAsRegion() const
Represents an SVal that is guaranteed to not be UnknownVal.
ConcreteInt evalComplement(SValBuilder &svalBuilder) const
const TypedValueRegion * getRegion() const
static raw_ostream & operator<<(raw_ostream &os, const clang::ento::MemRegion *R)
void dumpToStream(raw_ostream &OS) const
bool operator!=(const MemRegionVal &R) const
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
symbol_iterator symbol_begin() const
const SymExpr * getAsSymbolicExpression() const
getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression...
ConcreteInt(const llvm::APSInt &V)
const llvm::APSInt & getValue() const
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
const MemRegion * getRegion() const
Get the underlining region.
Iterator over symbols that the current symbol depends on.
const void * getStore() const