1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
//=== FlatStore.cpp - Flat region-based store model -------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Checker/PathSensitive/GRState.h"
#include "llvm/ADT/ImmutableIntervalMap.h"
using namespace clang;
// The actual store type.
typedef llvm::ImmutableIntervalMap<SVal> BindingVal;
typedef llvm::ImmutableMap<const MemRegion *, BindingVal> RegionBindings;
namespace {
class FlatStoreManager : public StoreManager {
RegionBindings::Factory RBFactory;
BindingVal::Factory BVFactory;
public:
FlatStoreManager(GRStateManager &mgr)
: StoreManager(mgr),
RBFactory(mgr.getAllocator()),
BVFactory(mgr.getAllocator()) {}
SVal Retrieve(const GRState *state, Loc loc, QualType T);
const GRState *Bind(const GRState *state, Loc loc, SVal val);
Store Remove(Store St, Loc L);
const GRState *BindCompoundLiteral(const GRState *state,
const CompoundLiteralExpr* cl,
const LocationContext *LC,
SVal v);
Store getInitialStore(const LocationContext *InitLoc) {
return RBFactory.GetEmptyMap().getRoot();
}
SubRegionMap *getSubRegionMap(const GRState *state);
SVal getLValueVar(const VarDecl *VD, const LocationContext *LC);
SVal getLValueString(const StringLiteral* sl);
SVal getLValueIvar(const ObjCIvarDecl* decl, SVal base);
SVal getLValueField(const FieldDecl* D, SVal Base);
SVal getLValueElement(QualType elementType, SVal offset, SVal Base);
SVal ArrayToPointer(Loc Array);
void RemoveDeadBindings(GRState &state, Stmt* Loc,
SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
const GRState *BindDecl(const GRState *ST, const VarRegion *VR, SVal initVal);
const GRState *BindDeclWithNoInit(const GRState *ST, const VarRegion *VR);
typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols;
const GRState *InvalidateRegion(const GRState *state,
const MemRegion *R,
const Expr *E, unsigned Count,
InvalidatedSymbols *IS);
void print(Store store, llvm::raw_ostream& Out, const char* nl,
const char *sep);
void iterBindings(Store store, BindingsHandler& f);
};
} // end anonymous namespace
StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) {
return new FlatStoreManager(StMgr);
}
SVal FlatStoreManager::Retrieve(const GRState *state, Loc loc, QualType T) {
return UnknownVal();
}
const GRState *FlatStoreManager::Bind(const GRState *state, Loc loc, SVal val) {
return state;
}
Store FlatStoreManager::Remove(Store store, Loc L) {
return store;
}
const GRState *FlatStoreManager::BindCompoundLiteral(const GRState *state,
const CompoundLiteralExpr* cl,
const LocationContext *LC,
SVal v) {
return state;
}
SubRegionMap *FlatStoreManager::getSubRegionMap(const GRState *state) {
return 0;
}
SVal FlatStoreManager::getLValueVar(const VarDecl *VD,
const LocationContext *LC) {
return UnknownVal();
}
SVal FlatStoreManager::getLValueString(const StringLiteral* sl) {
return UnknownVal();
}
SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) {
return UnknownVal();
}
SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) {
return UnknownVal();
}
SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset,
SVal Base) {
return UnknownVal();
}
SVal FlatStoreManager::ArrayToPointer(Loc Array) {
return Array;
}
void FlatStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) {
}
const GRState *FlatStoreManager::BindDecl(const GRState *state,
const VarRegion *VR, SVal initVal) {
return state;
}
const GRState *FlatStoreManager::BindDeclWithNoInit(const GRState *state,
const VarRegion *VR) {
return state;
}
const GRState *FlatStoreManager::InvalidateRegion(const GRState *state,
const MemRegion *R,
const Expr *E, unsigned Count,
InvalidatedSymbols *IS) {
return state;
}
void FlatStoreManager::print(Store store, llvm::raw_ostream& Out,
const char* nl, const char *sep) {
}
void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) {
}
|