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