clang: include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BASICVALUEFACTORY_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_BASICVALUEFACTORY_H
17
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"
31#include
32#include
33#include
34
36
37class CXXBaseSpecifier;
38
39namespace ento {
40
43 llvm::ImmutableList L;
44
45public:
48 }
49
50 using iterator = llvm::ImmutableList::iterator;
51
54
56
58 llvm::ImmutableList L);
59
61};
62
66
67public:
69 : store(st), region(r) {
70 assert(r);
72 }
73
74
76
77 LLVM_ATTRIBUTE_RETURNS_NONNULL
79
80 static void Profile(llvm::FoldingSetNodeID& ID,
83
85};
86
89 llvm::ImmutableList<const CXXBaseSpecifier *> L;
90
91public:
93 llvm::ImmutableList<const CXXBaseSpecifier *> L)
95
96 using iterator = llvm::ImmutableList<const CXXBaseSpecifier *>::iterator;
97
100
102 llvm::ImmutableList<const CXXBaseSpecifier *> L);
103
105
106
108
109 llvm::ImmutableList<const CXXBaseSpecifier *> getCXXBaseList() const {
110 return L;
111 }
112};
113
115 using APSIntSetTy =
116 llvm::FoldingSet<llvm::FoldingSetNodeWrapperllvm::APSInt>;
117
119 llvm::BumpPtrAllocator& BPAlloc;
120
121 APSIntSetTy APSIntSet;
122 void *PersistentSVals = nullptr;
123 void *PersistentSValPairs = nullptr;
124
125 llvm::ImmutableList::Factory SValListFactory;
126 llvm::ImmutableList<const CXXBaseSpecifier *>::Factory CXXBaseListFactory;
127 llvm::FoldingSet CompoundValDataSet;
128 llvm::FoldingSet LazyCompoundValDataSet;
129 llvm::FoldingSet PointerToMemberDataSet;
130
131
132
134
135public:
137 : Ctx(ctx), BPAlloc(Alloc), SValListFactory(Alloc),
138 CXXBaseListFactory(Alloc) {}
139
141
143
144 APSIntPtr getValue(const llvm::APSInt &X);
147
148
150
151
153 T = AT->getValueType();
154 }
155
159 } else {
160
162 }
163
164 llvm_unreachable("Unsupported type in getAPSIntType!");
165 }
166
167
168
172 return getValue(From);
173
174 return getValue(TargetType.convert(From));
175 }
176
179 return Convert(TargetType, From);
180 }
181
184 return getValue(From);
185
186 return getValue(TargetType.convert(From));
187 }
188
192 }
193
196 }
197
200 }
201
203
205
207
209
212 ++X;
213 return getValue(X);
214 }
215
218 --X;
219 return getValue(X);
220 }
221
224 return getValue(0, Ctx.getTypeSize(T), true);
225 }
226
230 }
231
234 }
235
237 llvm::ImmutableList Vals);
238
241
244 llvm::ImmutableList<const CXXBaseSpecifier *> L);
245
247 return SValListFactory.getEmptyList();
248 }
249
250 llvm::ImmutableList prependSVal(SVal X, llvm::ImmutableList L) {
251 return SValListFactory.add(X, L);
252 }
253
255 return CXXBaseListFactory.getEmptyList();
256 }
257
260 llvm::ImmutableList<const CXXBaseSpecifier *> L) {
261 return CXXBaseListFactory.add(CBS, L);
262 }
263
265 accumCXXBase(llvm::iterator_rangeCastExpr::path\_const\_iterator PathRange,
267
269 const llvm::APSInt &V1,
270 const llvm::APSInt &V2);
271
272 const std::pair<SVal, uintptr_t>&
274
275 const std::pair<SVal, SVal>&
277
279};
280
281}
282
283}
284
285#endif
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'.
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...