clang: include/clang/StaticAnalyzer/Core/PathSensitive/Store.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STORE_H
14#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STORE_H
15
24#include "llvm/ADT/ArrayRef.h"
25#include "llvm/ADT/DenseSet.h"
26#include "llvm/ADT/SmallVector.h"
27#include
28#include
29#include
30#include
31
33
34class ASTContext;
35class CastExpr;
36class CompoundLiteralExpr;
37class CXXBasePath;
39class Expr;
40class LocationContext;
41class ObjCIvarDecl;
42class StackFrameContext;
43
44namespace ento {
45
46class CallEvent;
47class ProgramStateManager;
48class ScanReachableSymbols;
49class SymbolReaper;
50
52
54protected:
57
58
61
63
64public:
66
67
68
69
70
71
72
73
75
76
77
78
79
80
81
82
83
84
85
88
89
90
91
92
93
94
95
96
99 }
100
101
102
103
104
105
106
107
109
110
111
112
115
116
117
119
120
121
122
124
125
126
128
129
130
132
134
137 }
138
142 }
143
145
147 return getLValueFieldOrIvar(D, Base);
148 }
149
151
152
153
155
156
157
159
160
162
163
165 bool IsVirtual);
166
167
168
169
170
171
172
173
174
175
176
177
179
181
182
183
184
187
190
192 const MemRegion *region) const = 0;
193
194
195
197
198
199
200
202
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
240
241
242
246
247
248
249
252
253 virtual void printJson(raw_ostream &Out, Store S, const char *NL,
254 unsigned int Space, bool IsDot) const = 0;
255
257 public:
259
260
263 };
264
267 const MemRegion* Binding = nullptr;
268 bool First = true;
269
270 public:
272
273 explicit operator bool() { return First && Binding; }
274
276 SVal val) override;
278 };
279
280
282
283protected:
286 uint64_t index = 0);
287
288private:
290};
291
293 : store(store), mgr(smgr) {
294 if (store)
296}
297
299 : store(sr.store), mgr(sr.mgr)
300{
301 if (store)
303}
304
306 if (store)
308}
309
311 assert(&newStore.mgr == &mgr);
312 if (store != newStore.store) {
316 }
317 return *this;
318}
319
320
321std::unique_ptr
323
324}
325
326}
327
328#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CompoundLiteralExpr - [C99 6.5.2.5].
Decl - This represents one declaration (or definition), e.g.
Represents a member of a struct/union/class.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
ObjCIvarDecl - Represents an ObjC instance variable.
A (possibly-)qualified type.
It represents a stack frame of the call stack (based on CallEvent).
Stmt - This represents one statement.
Represents a variable declaration or definition.
Represents an abstract call to a function or method along a particular path.
ElementRegion is used to represent both array elements and casts.
const CompoundLiteralRegion * getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC)
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
MemRegion - The root abstract class for all memory regions.
Information about invalidation for a particular region/symbol.
loc::MemRegionVal makeLoc(SymbolRef sym)
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
A utility class that visits the reachable symbols using a custom SymbolVisitor.
virtual ~BindingsHandler()
virtual bool HandleBinding(StoreManager &SMgr, Store store, const MemRegion *region, SVal val)=0
const MemRegion * getRegion()
bool HandleBinding(StoreManager &SMgr, Store store, const MemRegion *R, SVal val) override
FindUniqueBinding(SymbolRef sym)
SVal evalDerivedToBase(SVal Derived, const CastExpr *Cast)
Evaluates a chain of derived-to-base casts through the path specified in Cast.
ProgramStateManager & StateMgr
SValBuilder & getSValBuilder()
virtual StoreRef invalidateRegions(Store store, ArrayRef< SVal > Values, const Stmt *S, unsigned Count, const LocationContext *LCtx, const CallEvent *Call, InvalidatedSymbols &IS, RegionAndSymbolInvalidationTraits &ITraits, InvalidatedRegions *TopLevelRegions, InvalidatedRegions *Invalidated)=0
invalidateRegions - Clears out the specified regions from the store, marking their values as unknown.
virtual SVal getLValueField(const FieldDecl *D, SVal Base)
virtual bool scanReachableSymbols(Store S, const MemRegion *R, ScanReachableSymbols &Visitor)=0
Finds the transitive closure of symbols within the given region.
virtual StoreRef Bind(Store store, Loc loc, SVal val)=0
Return a store with the specified value bound to the given location.
MemRegionManager & getRegionManager()
getRegionManager - Returns the internal RegionManager object that is used to query and manipulate Mem...
std::optional< SVal > evalBaseToDerived(SVal Base, QualType DerivedPtrType)
Attempts to do a down cast.
const ElementRegion * MakeElementRegion(const SubRegion *baseRegion, QualType pointeeTy, uint64_t index=0)
StoreRef enterStackFrame(Store store, const CallEvent &Call, const StackFrameContext *CalleeCtx)
enterStackFrame - Let the StoreManager to do something when execution engine is about to execute into...
virtual void iterBindings(Store store, BindingsHandler &f)=0
iterBindings - Iterate over the bindings in the Store.
MemRegionManager & MRMgr
MRMgr - Manages region objects associated with this StoreManager.
SValBuilder & svalBuilder
virtual StoreRef getInitialStore(const LocationContext *InitLoc)=0
getInitialStore - Returns the initial "empty" store representing the value bindings upon entry to an ...
virtual SVal getLValueIvar(const ObjCIvarDecl *decl, SVal base)
virtual StoreRef BindDefaultZero(Store store, const MemRegion *R)=0
Return a store with in which all values within the given region are reset to zero.
virtual std::optional< SVal > getDefaultBinding(Store store, const MemRegion *R)=0
Return the default value bound to a region in a given store.
virtual StoreRef killBinding(Store ST, Loc L)=0
Create a new store with the specified binding removed.
virtual void decrementReferenceCount(Store store)
If the StoreManager supports it, decrement the reference count of the specified Store object.
virtual StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx, SymbolReaper &SymReaper)=0
virtual ~StoreManager()=default
virtual void incrementReferenceCount(Store store)
If the StoreManager supports it, increment the reference count of the specified Store object.
virtual SVal ArrayToPointer(Loc Array, QualType ElementTy)=0
ArrayToPointer - Used by ExprEngine::VistCast to handle implicit conversions between arrays and point...
virtual bool includedInBindings(Store store, const MemRegion *region) const =0
virtual SVal getBinding(Store store, Loc loc, QualType T=QualType())=0
Return the value bound to specified location in a given state.
virtual StoreRef BindDefaultInitial(Store store, const MemRegion *R, SVal V)=0
Return a store with the specified value bound to all sub-regions of the region.
std::optional< SVal > getDefaultBinding(nonloc::LazyCompoundVal lcv)
Return the default value bound to a LazyCompoundVal.
virtual Loc getLValueVar(const VarDecl *VD, const LocationContext *LC)
const ElementRegion * GetElementZeroRegion(const SubRegion *R, QualType T)
virtual SVal getLValueElement(QualType elementType, NonLoc offset, SVal Base)
virtual void printJson(raw_ostream &Out, Store S, const char *NL, unsigned int Space, bool IsDot) const =0
std::optional< const MemRegion * > castRegion(const MemRegion *region, QualType CastToTy)
castRegion - Used by ExprEngine::VisitCast to handle casts from a MemRegion* to a specific location t...
Loc getLValueCompoundLiteral(const CompoundLiteralExpr *CL, const LocationContext *LC)
StoreRef & operator=(StoreRef const &newStore)
StoreRef(Store store, StoreManager &smgr)
SubRegion - A region that subsets another larger region.
A class responsible for cleaning up unused symbols.
While nonloc::CompoundVal covers a few simple use cases, nonloc::LazyCompoundVal is a more performant...
LLVM_ATTRIBUTE_RETURNS_NONNULL const TypedValueRegion * getRegion() const
This function itself is immaterial.
const void * getStore() const
It might return null.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
llvm::DenseSet< SymbolRef > InvalidatedSymbols
std::unique_ptr< StoreManager > CreateRegionStoreManager(ProgramStateManager &StMgr)
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T