15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BASICVALUEFACTORY_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BASICVALUEFACTORY_H
26#include "llvm/ADT/APSInt.h"
27#include "llvm/ADT/FoldingSet.h"
28#include "llvm/ADT/ImmutableList.h"
29#include "llvm/ADT/iterator_range.h"
30#include "llvm/Support/Allocator.h"
37class CXXBaseSpecifier;
43 llvm::ImmutableList<SVal> L;
50 using iterator = llvm::ImmutableList<SVal>::iterator;
58 llvm::ImmutableList<SVal> L);
69 : store(st), region(r) {
77 LLVM_ATTRIBUTE_RETURNS_NONNULL
80 static void Profile(llvm::FoldingSetNodeID&
ID,
89 llvm::ImmutableList<const CXXBaseSpecifier *> L;
93 llvm::ImmutableList<const CXXBaseSpecifier *> L)
96 using iterator = llvm::ImmutableList<const CXXBaseSpecifier *>::iterator;
102 llvm::ImmutableList<const CXXBaseSpecifier *> L);
116 llvm::FoldingSet<llvm::FoldingSetNodeWrapper<llvm::APSInt>>;
119 llvm::BumpPtrAllocator& BPAlloc;
121 APSIntSetTy APSIntSet;
122 void *PersistentSVals =
nullptr;
123 void *PersistentSValPairs =
nullptr;
125 llvm::ImmutableList<SVal>::Factory SValListFactory;
126 llvm::ImmutableList<const CXXBaseSpecifier *>::Factory CXXBaseListFactory;
127 llvm::FoldingSet<CompoundValData> CompoundValDataSet;
128 llvm::FoldingSet<LazyCompoundValData> LazyCompoundValDataSet;
129 llvm::FoldingSet<PointerToMemberData> PointerToMemberDataSet;
137 : Ctx(ctx), BPAlloc(Alloc), SValListFactory(Alloc),
138 CXXBaseListFactory(Alloc) {}
153 T = AT->getValueType();
164 llvm_unreachable(
"Unsupported type in getAPSIntType!");
172 return getValue(From);
174 return getValue(TargetType.
convert(From));
179 return Convert(TargetType, From);
184 return getValue(From);
186 return getValue(TargetType.
convert(From));
191 return getValue(
X,
T);
237 llvm::ImmutableList<SVal> Vals);
244 llvm::ImmutableList<const CXXBaseSpecifier *> L);
247 return SValListFactory.getEmptyList();
251 return SValListFactory.add(
X, L);
255 return CXXBaseListFactory.getEmptyList();
260 llvm::ImmutableList<const CXXBaseSpecifier *> L) {
261 return CXXBaseListFactory.add(CBS, L);
265 accumCXXBase(llvm::iterator_range<CastExpr::path_const_iterator> PathRange,
269 const llvm::APSInt &V1,
270 const llvm::APSInt &V2);
272 const std::pair<SVal, uintptr_t>&
275 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 safe wrapper around APSInt objects allocated and owned by BasicValueFactory.
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.
APSIntPtr getMaxValue(const llvm::APSInt &v)
const CompoundValData * getCompoundValData(QualType T, llvm::ImmutableList< SVal > Vals)
const std::pair< SVal, SVal > & getPersistentSValPair(const SVal &V1, const SVal &V2)
APSIntPtr getZeroWithTypeSize(QualType T)
APSIntPtr Add1(const llvm::APSInt &V)
APSIntPtr getMinValue(QualType T)
APSIntPtr getMaxValue(QualType T)
APSIntPtr getIntValue(uint64_t X, bool isUnsigned)
const SVal * getPersistentSVal(SVal X)
BasicValueFactory(ASTContext &ctx, llvm::BumpPtrAllocator &Alloc)
APSIntPtr getMaxValue(APSIntType T)
APSIntPtr getMinValue(const llvm::APSInt &v)
const std::pair< SVal, uintptr_t > & getPersistentSValWithData(const SVal &V, uintptr_t Data)
APSIntType getAPSIntType(QualType T) const
Returns the type of the APSInt used to store values of the given QualType.
std::optional< APSIntPtr > evalAPSInt(BinaryOperator::Opcode Op, const llvm::APSInt &V1, const llvm::APSInt &V2)
ASTContext & getContext() const
APSIntPtr getTruthValue(bool b, QualType T)
const PointerToMemberData * getPointerToMemberData(const NamedDecl *ND, llvm::ImmutableList< const CXXBaseSpecifier * > L)
APSIntPtr Convert(QualType T, const llvm::APSInt &From)
llvm::ImmutableList< const CXXBaseSpecifier * > prependCXXBase(const CXXBaseSpecifier *CBS, llvm::ImmutableList< const CXXBaseSpecifier * > L)
llvm::ImmutableList< const CXXBaseSpecifier * > getEmptyCXXBaseList()
APSIntPtr Convert(APSIntType TargetType, const llvm::APSInt &From)
APSIntPtr 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...
const LazyCompoundValData * getLazyCompoundValData(const StoreRef &store, const TypedValueRegion *region)
const PointerToMemberData * accumCXXBase(llvm::iterator_range< CastExpr::path_const_iterator > PathRange, const nonloc::PointerToMember &PTM, const clang::CastKind &kind)
APSIntPtr Sub1(const llvm::APSInt &V)
APSIntPtr getMinValue(APSIntType T)
llvm::ImmutableList< SVal > getEmptySValList()
APSIntPtr getTruthValue(bool b)
llvm::ImmutableList< SVal > prependSVal(SVal X, llvm::ImmutableList< SVal > L)
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.
void Profile(llvm::FoldingSetNodeID &ID)
LLVM_ATTRIBUTE_RETURNS_NONNULL const TypedValueRegion * getRegion() const
static bool isLocType(QualType T)
static bool isCompoundType(QualType T)
llvm::ImmutableList< const CXXBaseSpecifier * > getCXXBaseList() const
void Profile(llvm::FoldingSetNodeID &ID)
llvm::ImmutableList< const CXXBaseSpecifier * >::iterator iterator
const NamedDecl * getDeclaratorDecl() const
It might return null.
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.
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...