15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BASICVALUEFACTORY_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BASICVALUEFACTORY_H
25 #include "llvm/ADT/APSInt.h"
26 #include "llvm/ADT/FoldingSet.h"
27 #include "llvm/ADT/ImmutableList.h"
28 #include "llvm/ADT/iterator_range.h"
29 #include "llvm/Support/Allocator.h"
36 class CXXBaseSpecifier;
42 llvm::ImmutableList<SVal> L;
49 using iterator = llvm::ImmutableList<SVal>::iterator;
57 llvm::ImmutableList<SVal> L);
68 : store(st), region(r) {
76 LLVM_ATTRIBUTE_RETURNS_NONNULL
79 static void Profile(llvm::FoldingSetNodeID&
ID,
88 llvm::ImmutableList<const CXXBaseSpecifier *> L;
92 llvm::ImmutableList<const CXXBaseSpecifier *> L)
95 using iterator = llvm::ImmutableList<const CXXBaseSpecifier *>::iterator;
101 llvm::ImmutableList<const CXXBaseSpecifier *> L);
115 llvm::FoldingSet<llvm::FoldingSetNodeWrapper<llvm::APSInt>>;
118 llvm::BumpPtrAllocator& BPAlloc;
120 APSIntSetTy APSIntSet;
121 void *PersistentSVals =
nullptr;
122 void *PersistentSValPairs =
nullptr;
124 llvm::ImmutableList<SVal>::Factory SValListFactory;
125 llvm::ImmutableList<const CXXBaseSpecifier *>::Factory CXXBaseListFactory;
126 llvm::FoldingSet<CompoundValData> CompoundValDataSet;
127 llvm::FoldingSet<LazyCompoundValData> LazyCompoundValDataSet;
128 llvm::FoldingSet<PointerToMemberData> PointerToMemberDataSet;
136 : Ctx(ctx), BPAlloc(Alloc), SValListFactory(Alloc),
137 CXXBaseListFactory(Alloc) {}
152 T = AT->getValueType();
163 llvm_unreachable(
"Unsupported type in getAPSIntType!");
174 return getValue(TargetType.
convert(From));
179 return Convert(TargetType, From);
186 return getValue(TargetType.
convert(From));
191 return getValue(
X,
T);
211 return getValue(
T.getMaxValue());
215 return getValue(
T.getMinValue());
245 llvm::ImmutableList<SVal> Vals);
252 llvm::ImmutableList<const CXXBaseSpecifier *> L);
255 return SValListFactory.getEmptyList();
259 return SValListFactory.add(
X, L);
263 return CXXBaseListFactory.getEmptyList();
268 llvm::ImmutableList<const CXXBaseSpecifier *> L) {
269 return CXXBaseListFactory.add(CBS, L);
273 accumCXXBase(llvm::iterator_range<CastExpr::path_const_iterator> PathRange,
280 const std::pair<SVal, uintptr_t>&
283 const std::pair<SVal, SVal>&
Defines the clang::ASTContext interface.
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned getIntWidth(QualType T) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedIntTy
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
Represents a base class of a C++ class.
This represents a decl that may have a name.
A (possibly-)qualified type.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isScalarType() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isUnsignedFixedPointType() const
Return true if this is a fixed point type that is unsigned according to ISO/IEC JTC1 SC22 WG14 N1169.
const T * getAs() const
Member-template getAs<specific type>'.
A record of the "type" of an APSInt, used for conversions.
llvm::APSInt convert(const llvm::APSInt &Value) const LLVM_READONLY
Convert and return a new APSInt with the given value, but this type's bit width and signedness.
llvm::ImmutableList< const CXXBaseSpecifier * > prependCXXBase(const CXXBaseSpecifier *CBS, llvm::ImmutableList< const CXXBaseSpecifier * > L)
const llvm::APSInt & getMaxValue(APSIntType T)
const CompoundValData * getCompoundValData(QualType T, llvm::ImmutableList< SVal > Vals)
const std::pair< SVal, SVal > & getPersistentSValPair(const SVal &V1, const SVal &V2)
const llvm::APSInt & getTruthValue(bool b, QualType T)
const llvm::APSInt & getTruthValue(bool b)
const SVal * getPersistentSVal(SVal X)
BasicValueFactory(ASTContext &ctx, llvm::BumpPtrAllocator &Alloc)
const llvm::APSInt & getMinValue(QualType T)
const llvm::APSInt & Add1(const llvm::APSInt &V)
const llvm::APSInt & getMinValue(APSIntType T)
const std::pair< SVal, uintptr_t > & getPersistentSValWithData(const SVal &V, uintptr_t Data)
const llvm::APSInt & Sub1(const llvm::APSInt &V)
const llvm::APSInt * evalAPSInt(BinaryOperator::Opcode Op, const llvm::APSInt &V1, const llvm::APSInt &V2)
const llvm::APSInt & getMaxValue(const llvm::APSInt &v)
APSIntType getAPSIntType(QualType T) const
Returns the type of the APSInt used to store values of the given QualType.
const PointerToMemberData * getPointerToMemberData(const NamedDecl *ND, llvm::ImmutableList< const CXXBaseSpecifier * > L)
const llvm::APSInt & Convert(const llvm::APSInt &To, const llvm::APSInt &From)
Convert - Create a new persistent APSInt with the same value as 'From' but with the bitwidth and sign...
llvm::ImmutableList< SVal > prependSVal(SVal X, llvm::ImmutableList< SVal > L)
const llvm::APSInt & getIntValue(uint64_t X, bool isUnsigned)
const LazyCompoundValData * getLazyCompoundValData(const StoreRef &store, const TypedValueRegion *region)
llvm::ImmutableList< const CXXBaseSpecifier * > getEmptyCXXBaseList()
const PointerToMemberData * accumCXXBase(llvm::iterator_range< CastExpr::path_const_iterator > PathRange, const nonloc::PointerToMember &PTM, const clang::CastKind &kind)
const llvm::APSInt & getZeroWithTypeSize(QualType T)
const llvm::APSInt & Convert(QualType T, const llvm::APSInt &From)
const llvm::APSInt & getMaxValue(QualType T)
llvm::ImmutableList< SVal > getEmptySValList()
ASTContext & getContext() const
const llvm::APSInt & getMinValue(const llvm::APSInt &v)
const llvm::APSInt & Convert(APSIntType TargetType, const llvm::APSInt &From)
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, llvm::ImmutableList< SVal > L)
llvm::ImmutableList< SVal >::iterator iterator
void Profile(llvm::FoldingSetNodeID &ID)
CompoundValData(QualType t, llvm::ImmutableList< SVal > l)
static void Profile(llvm::FoldingSetNodeID &ID, const StoreRef &store, const TypedValueRegion *region)
LazyCompoundValData(const StoreRef &st, const TypedValueRegion *r)
const void * getStore() const
It might return null.
LLVM_ATTRIBUTE_RETURNS_NONNULL const TypedValueRegion * getRegion() const
void Profile(llvm::FoldingSetNodeID &ID)
static bool isLocType(QualType T)
static bool isCompoundType(QualType T)
void Profile(llvm::FoldingSetNodeID &ID)
const NamedDecl * getDeclaratorDecl() const
It might return null.
llvm::ImmutableList< const CXXBaseSpecifier * >::iterator iterator
llvm::ImmutableList< const CXXBaseSpecifier * > getCXXBaseList() const
static void Profile(llvm::FoldingSetNodeID &ID, const NamedDecl *D, llvm::ImmutableList< const CXXBaseSpecifier * > L)
PointerToMemberData(const NamedDecl *D, llvm::ImmutableList< const CXXBaseSpecifier * > L)
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
TypedValueRegion - An abstract class representing regions having a typed value.
virtual QualType getValueType() const =0
Value representing pointer-to-member.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
The JSON file list parser is used to communicate input to InstallAPI.
CastKind
CastKind - The kind of operation required for a conversion.
const FunctionProtoType * T
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...