blob: ceb9870107154d205d51e9772b4208db5e790211 [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
30 SValuator::CastResult Retrieve(const GRState *state, Loc loc, QualType T);
31 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
76SValuator::CastResult FlatStoreManager::Retrieve(const GRState *state, Loc loc,
77 QualType T) {
78 return SValuator::CastResult(state, UnknownVal());
79}
80
81const GRState *FlatStoreManager::Bind(const GRState *state, Loc loc, SVal val) {
82 return state;
83}
84
85Store FlatStoreManager::Remove(Store store, Loc L) {
86 return store;
87}
88
89const GRState *FlatStoreManager::BindCompoundLiteral(const GRState *state,
90 const CompoundLiteralExpr* cl,
91 const LocationContext *LC,
92 SVal v) {
93 return state;
94}
95
96
97SubRegionMap *FlatStoreManager::getSubRegionMap(const GRState *state) {
98 return 0;
99}
100
101SVal FlatStoreManager::getLValueVar(const VarDecl *VD,
102 const LocationContext *LC) {
103 return UnknownVal();
104}
105
106SVal FlatStoreManager::getLValueString(const StringLiteral* sl) {
107 return UnknownVal();
108}
109
110SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) {
111 return UnknownVal();
112}
113
114SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) {
115 return UnknownVal();
116}
117
118SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset,
119 SVal Base) {
120 return UnknownVal();
121}
122
123SVal FlatStoreManager::ArrayToPointer(Loc Array) {
124 return Array;
125}
126
127void FlatStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
128 SymbolReaper& SymReaper,
129 llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) {
130}
131
132const GRState *FlatStoreManager::BindDecl(const GRState *state,
133 const VarRegion *VR, SVal initVal) {
134 return state;
135}
136
137const GRState *FlatStoreManager::BindDeclWithNoInit(const GRState *state,
138 const VarRegion *VR) {
139 return state;
140}
141
142const GRState *FlatStoreManager::InvalidateRegion(const GRState *state,
143 const MemRegion *R,
144 const Expr *E, unsigned Count,
145 InvalidatedSymbols *IS) {
146 return state;
147}
148
149void FlatStoreManager::print(Store store, llvm::raw_ostream& Out,
150 const char* nl, const char *sep) {
151}
152
153void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) {
154}