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());
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();
90const llvm::APSInt& BasicValueFactory::getValue(
const llvm::APSInt&
X) {
91 llvm::FoldingSetNodeID ID;
94 using FoldNodeTy = llvm::FoldingSetNodeWrapper<llvm::APSInt>;
97 FoldNodeTy*
P = APSIntSet.FindNodeOrInsertPos(ID, InsertPos);
100 P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
101 new (
P) FoldNodeTy(
X);
102 APSIntSet.InsertNode(
P, InsertPos);
108const llvm::APSInt& BasicValueFactory::getValue(
const llvm::APInt&
X,
110 llvm::APSInt
V(
X, isUnsigned);
114const llvm::APSInt& BasicValueFactory::getValue(uint64_t
X,
unsigned BitWidth,
116 llvm::APSInt
V(BitWidth, isUnsigned);
121const llvm::APSInt& BasicValueFactory::getValue(uint64_t
X,
QualType T) {
127 llvm::ImmutableList<SVal> Vals) {
128 llvm::FoldingSetNodeID ID;
132 CompoundValData* D = CompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
137 CompoundValDataSet.InsertNode(D, InsertPos);
146 llvm::FoldingSetNodeID ID;
151 LazyCompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
156 LazyCompoundValDataSet.InsertNode(D, InsertPos);
163 const NamedDecl *ND, llvm::ImmutableList<const CXXBaseSpecifier *> L) {
164 llvm::FoldingSetNodeID ID;
169 PointerToMemberDataSet.FindNodeOrInsertPos(ID, InsertPos);
174 PointerToMemberDataSet.InsertNode(D, InsertPos);
181 llvm::ImmutableList<const CXXBaseSpecifier *> BaseSpecList) {
184 QualType BaseType = BaseSpec->getType();
186 if (!BaseSpecSeen.insert(BaseType).second)
193 llvm::iterator_range<CastExpr::path_const_iterator> PathRange,
195 assert((kind == CK_DerivedToBaseMemberPointer ||
196 kind == CK_BaseToDerivedMemberPointer ||
197 kind == CK_ReinterpretMemberPointer) &&
198 "accumCXXBase called with wrong CastKind");
201 llvm::ImmutableList<const CXXBaseSpecifier *> BaseSpecList;
203 if (PTMDT.isNull() || PTMDT.is<
const NamedDecl *>()) {
207 BaseSpecList = CXXBaseListFactory.getEmptyList();
216 "CXXBaseSpecifier list of PointerToMemberData must not have repeated "
219 if (kind == CK_DerivedToBaseMemberPointer) {
230 auto ReducedBaseSpecList = CXXBaseListFactory.getEmptyList();
233 return BaseSpec->getType() == I->getType();
235 if (llvm::none_of(PathRange, IsSameAsBaseSpec))
236 ReducedBaseSpecList =
237 CXXBaseListFactory.add(BaseSpec, ReducedBaseSpecList);
251 const llvm::APSInt& V1,
const llvm::APSInt& V2) {
254 llvm_unreachable(
"Invalid Opcode.");
257 return &getValue( V1 * V2 );
262 return &getValue( V1 / V2 );
267 return &getValue( V1 % V2 );
270 return &getValue( V1 + V2 );
273 return &getValue( V1 - V2 );
279 if (V2.isSigned() && V2.isNegative())
282 uint64_t Amt = V2.getZExtValue();
284 if (Amt >= V1.getBitWidth())
288 if (V1.isSigned() && V1.isNegative())
291 if (V1.isSigned() && Amt > V1.countl_zero())
295 return &getValue( V1.operator<<( (
unsigned) Amt ));
302 if (V2.isSigned() && V2.isNegative())
305 uint64_t Amt = V2.getZExtValue();
307 if (Amt >= V1.getBitWidth())
310 return &getValue( V1.operator>>( (
unsigned) Amt ));
334 return &getValue( V1 & V2 );
337 return &getValue( V1 | V2 );
340 return &getValue( V1 ^ V2 );
344const std::pair<SVal, uintptr_t>&
349 llvm::FoldingSetNodeID ID;
352 ID.AddPointer((
void*)
Data);
356 using FoldNodeTy = llvm::FoldingSetNodeWrapper<SValData>;
358 FoldNodeTy*
P = Map.FindNodeOrInsertPos(ID, InsertPos);
361 P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
362 new (
P) FoldNodeTy(std::make_pair(
V,
Data));
363 Map.InsertNode(
P, InsertPos);
366 return P->getValue();
369const std::pair<SVal, SVal>&
374 llvm::FoldingSetNodeID ID;
381 using FoldNodeTy = llvm::FoldingSetNodeWrapper<SValPair>;
383 FoldNodeTy*
P = Map.FindNodeOrInsertPos(ID, InsertPos);
386 P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
387 new (
P) FoldNodeTy(std::make_pair(V1, V2));
388 Map.InsertNode(
P, InsertPos);
391 return P->getValue();
std::pair< SVal, SVal > SValPair
llvm::FoldingSet< llvm::FoldingSetNodeWrapper< SValData > > PersistentSValsTy
llvm::FoldingSet< llvm::FoldingSetNodeWrapper< SValPair > > PersistentSValPairsTy
std::pair< SVal, uintptr_t > SValData
LLVM_ATTRIBUTE_UNUSED bool hasNoRepeatedElements(llvm::ImmutableList< const CXXBaseSpecifier * > BaseSpecList)
static CompilationDatabasePluginRegistry::Add< FixedCompilationDatabasePlugin > X("fixed-compilation-database", "Reads plain-text flags file")
const LangOptions & getLangOpts() const
Represents a base class of a C++ class.
This represents a decl that may have a name.
A (possibly-)qualified type.
void Profile(llvm::FoldingSetNodeID &ID) const
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 llvm::APSInt & getTruthValue(bool b, QualType T)
const std::pair< SVal, uintptr_t > & getPersistentSValWithData(const SVal &V, uintptr_t Data)
const llvm::APSInt * evalAPSInt(BinaryOperator::Opcode Op, const llvm::APSInt &V1, const llvm::APSInt &V2)
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)
llvm::ImmutableList< const CXXBaseSpecifier * > prependCXXBase(const CXXBaseSpecifier *CBS, llvm::ImmutableList< const CXXBaseSpecifier * > L)
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)
llvm::ImmutableList< const CXXBaseSpecifier * > getCXXBaseList() const
const NamedDecl * getDeclaratorDecl() const
It might return null.
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
CastKind
CastKind - The kind of operation required for a conversion.
YAML serialization mapping.
__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)