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

43

44namespace ento {

45

50

52

60

62protected:

65

66

69

71

72public:

74

75

76

77

78

79

80

81

83

84

85

86

87

88

89

90

91

92

93

96

97

98

99

100

101

102

103

104

108

109

110

111

112

113

114

115

117

118

119

120

123

124

125

127

128

129

130

132

133

134

136

137

138

140

142

146

151

153

155 return getLValueFieldOrIvar(D, Base);

156 }

157

159

160

161

163

164

165

167

168

170

171

173 bool IsVirtual);

174

175

176

177

178

179

180

181

182

183

184

185

187

189

190

191

192

195

198

200 const MemRegion *region) const = 0;

201

202

203

205

206

207

208

210

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

248

249

250

253

254

255

256

259

260 virtual void printJson(raw_ostream &Out, Store S, const char *NL,

261 unsigned int Space, bool IsDot) const = 0;

262

264 public:

266

267

270 };

271

274 const MemRegion* Binding = nullptr;

275 bool First = true;

276

277 public:

279

280 explicit operator bool() { return First && Binding; }

281

283 SVal val) override;

285 };

286

287

289

290protected:

293 uint64_t index = 0);

294

295private:

297};

298

300 : store(store), mgr(smgr) {

301 if (store)

302 mgr.incrementReferenceCount(store);

303}

304

306 : store(sr.store), mgr(sr.mgr)

307{

308 if (store)

309 mgr.incrementReferenceCount(store);

310}

311

313 if (store)

314 mgr.decrementReferenceCount(store);

315}

316

318 assert(&newStore.mgr == &mgr);

319 if (store != newStore.store) {

320 mgr.incrementReferenceCount(newStore.store);

321 mgr.decrementReferenceCount(store);

323 }

324 return *this;

325}

326

327

328std::unique_ptr

330

331}

332

333}

334

335#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.

This represents one expression.

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).

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.

MemRegion - The root abstract class for all memory regions.

Information about invalidation for a particular region/symbol.

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()

Definition Store.h:284

bool HandleBinding(StoreManager &SMgr, Store store, const MemRegion *R, SVal val) override

FindUniqueBinding(SymbolRef sym)

Definition Store.h:278

SVal evalDerivedToBase(SVal Derived, const CastExpr *Cast)

Evaluates a chain of derived-to-base casts through the path specified in Cast.

ProgramStateManager & StateMgr

Definition Store.h:64

SValBuilder & getSValBuilder()

Definition Store.h:141

virtual StoreRef invalidateRegions(Store store, ArrayRef< SVal > Values, ConstCFGElementRef Elem, 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)

Definition Store.h:154

virtual bool scanReachableSymbols(Store S, const MemRegion *R, ScanReachableSymbols &Visitor)=0

Finds the transitive closure of symbols within the given region.

MemRegionManager & getRegionManager()

getRegionManager - Returns the internal RegionManager object that is used to query and manipulate Mem...

Definition Store.h:139

std::optional< SVal > evalBaseToDerived(SVal Base, QualType DerivedPtrType)

Attempts to do a down cast.

BindResult enterStackFrame(Store store, const CallEvent &Call, const StackFrameContext *CalleeCtx)

enterStackFrame - Let the StoreManager to do something when execution engine is about to execute into...

const ElementRegion * MakeElementRegion(const SubRegion *baseRegion, QualType pointeeTy, uint64_t index=0)

SmallVector< const MemRegion *, 8 > InvalidatedRegions

Definition Store.h:211

virtual BindResult Bind(Store store, Loc loc, SVal val)=0

Return a store with the specified value bound to the given location.

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.

Definition Store.h:67

SValBuilder & svalBuilder

Definition Store.h:63

virtual BindResult BindDefaultZero(Store store, const MemRegion *R)=0

Return a store with in which all values within the given region are reset to zero.

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 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.

Definition Store.h:209

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.

Definition Store.h:204

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.

StoreManager(ProgramStateManager &stateMgr)

std::optional< SVal > getDefaultBinding(nonloc::LazyCompoundVal lcv)

Return the default value bound to a LazyCompoundVal.

Definition Store.h:105

virtual Loc getLValueVar(const VarDecl *VD, const LocationContext *LC)

Definition Store.h:143

const ElementRegion * GetElementZeroRegion(const SubRegion *R, QualType T)

virtual BindResult BindDefaultInitial(Store store, const MemRegion *R, SVal V)=0

Return a store with the specified value bound to all sub-regions of the region.

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...

ASTContext & Ctx

Definition Store.h:68

Loc getLValueCompoundLiteral(const CompoundLiteralExpr *CL, const LocationContext *LC)

Definition Store.h:147

StoreRef & operator=(StoreRef const &newStore)

Definition Store.h:317

~StoreRef()

Definition Store.h:312

StoreRef(Store store, StoreManager &smgr)

Definition Store.h:299

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.

const internal::VariadicAllOfMatcher< Decl > decl

Matches declarations.

llvm::DenseSet< SymbolRef > InvalidatedSymbols

Definition Store.h:51

const SymExpr * SymbolRef

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.

CFGBlock::ConstCFGElementRef ConstCFGElementRef

const FunctionProtoType * T

llvm::SmallVector< SVal, 0 > FailedToBindValues

Definition Store.h:58

StoreRef ResultingStore

Definition Store.h:54