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;
36 class BasicValueFactory;
38 class TypedValueRegion;
39 class MemRegionManager;
40 class ProgramStateManager;
50 #define BASIC_SVAL(Id, Parent) Id ## Kind,
51 #define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
52 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
63 explicit SVal(
const void *d,
bool isLoc,
unsigned ValKind)
76 assert(T::isKind(*
this));
87 if (!T::isKind(*
this))
114 return !(*
this == R);
197 static bool isKind(
const SVal& V) {
206 bool isUndef()
const =
delete;
207 bool isValid()
const =
delete;
212 :
SVal(d, isLoc, ValKind) {}
219 static bool isKind(
const SVal& V) {
230 static bool isKind(
const SVal &V) {
239 bool isUnknown()
const =
delete;
240 bool isUnknownOrUndef()
const =
delete;
241 bool isValid()
const =
delete;
248 static bool isKind(
const SVal& V) {
258 static bool isKind(
const SVal &V) {
269 explicit NonLoc(
unsigned SubKind,
const void *d)
277 static bool isKind(
const SVal& V) {
285 explicit Loc(
unsigned SubKind,
const void *D)
298 static bool isKind(
const SVal& V) {
310 #define NONLOC_SVAL(Id, Parent) Id ## Kind,
311 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
330 static bool isKind(
const SVal& V) {
335 static bool isKind(
const NonLoc& V) {
346 return *
static_cast<const llvm::APSInt*
>(
Data);
360 static bool isKind(
const SVal& V) {
365 static bool isKind(
const NonLoc& V) {
373 explicit LocAsInteger(
const std::pair<SVal, uintptr_t> &data)
374 :
NonLoc(LocAsIntegerKind, &data) {
375 assert (data.first.getAs<
Loc>());
381 const std::pair<SVal, uintptr_t> *D =
382 static_cast<const std::pair<SVal, uintptr_t> *
>(
Data);
387 const std::pair<SVal, uintptr_t> *D =
388 static_cast<const std::pair<SVal, uintptr_t> *
>(
Data);
389 const SVal& V = D->first;
394 const std::pair<SVal, uintptr_t> *D =
395 static_cast<const std::pair<SVal, uintptr_t> *
>(
Data);
402 static bool isKind(
const SVal& V) {
407 static bool isKind(
const NonLoc& V) {
429 static bool isKind(
const SVal& V) {
433 static bool isKind(
const NonLoc& V) {
442 :
NonLoc(LazyCompoundValKind, D) {}
453 static bool isKind(
const SVal& V) {
457 static bool isKind(
const NonLoc& V) {
471 #define LOC_SVAL(Id, Parent) Id ## Kind,
472 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
486 static bool isKind(
const SVal& V) {
490 static bool isKind(
const Loc& V) {
508 template <
typename REGION>
524 static bool isKind(
const SVal& V) {
529 static bool isKind(
const Loc& V) {
539 return *
static_cast<const llvm::APSInt*
>(
Data);
549 static bool isKind(
const SVal& V) {
554 static bool isKind(
const Loc& V) {
572 template <
typename T>
struct isPodLike;
574 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)
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.
bool isZeroConstant() const
Loc getPersistentLoc() const
bool operator!=(const SVal &R) const
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.
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 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
unsigned getRawKind() const
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
MemRegionVal(const MemRegion *r)
unsigned Kind
The lowest 2 bits are a BaseKind (0 – 3).
const LazyCompoundValData * getCVData() const
NonLoc(unsigned SubKind, const void *d)
SVal evalBinOp(SValBuilder &svalBuilder, BinaryOperator::Opcode Op, const ConcreteInt &R) const
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...
SymbolRef getSymbol() const
ConcreteInt evalMinus(SValBuilder &svalBuilder) const
DefinedOrUnknownSVal(BaseKind k, void *D=nullptr)
GotoLabel(LabelDecl *Label)
unsigned getSubKind() const
const llvm::APSInt & getValue() const
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