20#include "llvm/ADT/APSInt.h"
21#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/ImmutableList.h"
23#include "llvm/ADT/STLExtras.h"
24#include "llvm/ADT/SmallPtrSet.h"
33 llvm::ImmutableList<SVal> L) {
35 ID.AddPointer(L.getInternalPointer());
41 ID.AddPointer(store.getStore());
42 ID.AddPointer(region);
46 llvm::FoldingSetNodeID &ID,
const NamedDecl *D,
47 llvm::ImmutableList<const CXXBaseSpecifier *> L) {
49 ID.AddPointer(L.getInternalPointer());
60 ID.AddPointer( (
void*)
X.second);
74 llvm::FoldingSet<llvm::FoldingSetNodeWrapper<SValData>>;
77 llvm::FoldingSet<llvm::FoldingSetNodeWrapper<SValPair>>;
83 for (
const auto &I : APSIntSet)
84 I.getValue().~APSInt();
90APSIntPtr BasicValueFactory::getValue(
const llvm::APSInt &
X) {
91 llvm::FoldingSetNodeID ID;
92 llvm::FoldingSetInsertToken InsertToken;
94 using FoldNodeTy = llvm::FoldingSetNodeWrapper<llvm::APSInt>;
97 FoldNodeTy *P = APSIntSet.lookup(ID, InsertToken);
100 P =
new (BPAlloc) FoldNodeTy(
X);
101 APSIntSet.insert(P, InsertToken);
113APSIntPtr BasicValueFactory::getValue(uint64_t
X,
unsigned BitWidth,
126 llvm::ImmutableList<SVal> Vals) {
127 llvm::FoldingSetNodeID ID;
129 llvm::FoldingSetInsertToken InsertToken;
135 CompoundValDataSet.insert(D, InsertToken);
144 llvm::FoldingSetNodeID ID;
146 llvm::FoldingSetInsertToken InsertToken;
152 LazyCompoundValDataSet.insert(D, InsertToken);
159 const NamedDecl *ND, llvm::ImmutableList<const CXXBaseSpecifier *> L) {
160 llvm::FoldingSetNodeID ID;
162 llvm::FoldingSetInsertToken InsertToken;
168 PointerToMemberDataSet.insert(D, InsertToken);
175 llvm::ImmutableList<const CXXBaseSpecifier *> BaseSpecList) {
178 QualType BaseType = BaseSpec->getType();
180 if (!BaseSpecSeen.insert(BaseType).second)
187 llvm::iterator_range<CastExpr::path_const_iterator> PathRange,
189 assert((
kind == CK_DerivedToBaseMemberPointer ||
190 kind == CK_BaseToDerivedMemberPointer ||
191 kind == CK_ReinterpretMemberPointer) &&
192 "accumCXXBase called with wrong CastKind");
195 llvm::ImmutableList<const CXXBaseSpecifier *> BaseSpecList;
198 if (
const auto *NDP = dyn_cast_if_present<const NamedDecl *>(PTMDT))
201 BaseSpecList = CXXBaseListFactory.getEmptyList();
204 ND = PTMD->getDeclaratorDecl();
206 BaseSpecList = PTMD->getCXXBaseList();
210 "CXXBaseSpecifier list of PointerToMemberData must not have repeated "
213 if (
kind == CK_DerivedToBaseMemberPointer) {
224 auto ReducedBaseSpecList = CXXBaseListFactory.getEmptyList();
227 return BaseSpec->getType() == I->getType();
229 if (llvm::none_of(PathRange, IsSameAsBaseSpec))
230 ReducedBaseSpecList =
231 CXXBaseListFactory.add(BaseSpec, ReducedBaseSpecList);
244 const llvm::APSInt &V1) {
247 assert(
false &&
"Invalid Opcode.");
251 return getValue(-V1);
254 return getValue(~V1);
258std::optional<APSIntPtr>
260 const llvm::APSInt &V2) {
263 assert(
false &&
"Invalid Opcode.");
267 return getValue(V1 * V2);
272 return getValue(V1 / V2);
277 return getValue(V1 % V2);
280 return getValue(V1 + V2);
283 return getValue(V1 - V2);
289 if (V2.isNegative() || V2.getBitWidth() > 64)
292 uint64_t Amt = V2.getZExtValue();
294 if (Amt >= V1.getBitWidth())
297 return getValue(V1.operator<<((
unsigned)Amt));
304 if (V2.isNegative() || V2.getBitWidth() > 64)
307 uint64_t Amt = V2.getZExtValue();
309 if (Amt >= V1.getBitWidth())
312 return getValue(V1.operator>>((
unsigned)Amt));
336 return getValue(V1 & V2);
339 return getValue(V1 | V2);
342 return getValue(V1 ^ V2);
346const std::pair<SVal, uintptr_t>&
351 llvm::FoldingSetNodeID ID;
352 llvm::FoldingSetInsertToken InsertToken;
354 ID.AddPointer((
void*)
Data);
358 using FoldNodeTy = llvm::FoldingSetNodeWrapper<SValData>;
360 FoldNodeTy *P = Map.lookup(ID, InsertToken);
363 P =
new (BPAlloc) FoldNodeTy(std::make_pair(
V,
Data));
364 Map.insert(P, InsertToken);
367 return P->getValue();
370const std::pair<SVal, SVal>&
375 llvm::FoldingSetNodeID ID;
376 llvm::FoldingSetInsertToken InsertToken;
382 using FoldNodeTy = llvm::FoldingSetNodeWrapper<SValPair>;
384 FoldNodeTy *P = Map.lookup(ID, InsertToken);
387 P =
new (BPAlloc) FoldNodeTy(std::make_pair(V1, V2));
388 Map.insert(P, InsertToken);
391 return P->getValue();
std::pair< SVal, SVal > SValPair
static bool hasNoRepeatedElements(llvm::ImmutableList< const CXXBaseSpecifier * > BaseSpecList)
std::pair< SVal, uintptr_t > SValData
llvm::FoldingSet< llvm::FoldingSetNodeWrapper< SValData > > PersistentSValsTy
llvm::FoldingSet< llvm::FoldingSetNodeWrapper< SValPair > > PersistentSValPairsTy
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
BinaryOperatorKind Opcode
Represents a base class of a C++ class.
This represents a decl that may have a name.
A (possibly-)qualified type.
A safe wrapper around APSInt objects allocated and owned by BasicValueFactory.
static APSIntPtr unsafeConstructor(const APSInt *Ptr)
You should not use this API.
const CompoundValData * getCompoundValData(QualType T, llvm::ImmutableList< SVal > Vals)
const std::pair< SVal, SVal > & getPersistentSValPair(const SVal &V1, const SVal &V2)
const SVal * getPersistentSVal(SVal X)
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.
APSIntPtr getTruthValue(bool b, QualType T)
const PointerToMemberData * getPointerToMemberData(const NamedDecl *ND, llvm::ImmutableList< const CXXBaseSpecifier * > L)
llvm::ImmutableList< const CXXBaseSpecifier * > prependCXXBase(const CXXBaseSpecifier *CBS, llvm::ImmutableList< const CXXBaseSpecifier * > L)
std::optional< APSIntPtr > evalAPSInt(UnaryOperator::Opcode Op, const llvm::APSInt &V1)
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)
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, llvm::ImmutableList< SVal > L)
static void Profile(llvm::FoldingSetNodeID &ID, const StoreRef &store, const TypedValueRegion *region)
static void Profile(llvm::FoldingSetNodeID &ID, 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.
void Profile(llvm::FoldingSetNodeID &ID) const
TypedValueRegion - An abstract class representing regions having a typed value.
Value representing pointer-to-member.
llvm::PointerUnion< const NamedDecl *, const PointerToMemberData * > PTMDataType
const PTMDataType getPTMData() const
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
const FunctionProtoType * T
CastKind
CastKind - The kind of operation required for a conversion.
U cast(CodeGen::Address addr)
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
static void Profile(const SValData &X, llvm::FoldingSetNodeID &ID)
static void Profile(const SValPair &X, llvm::FoldingSetNodeID &ID)