blob: e9246642ed49e7945b3356e43cd6cdcf990c3412 [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 Xub4a9c612010-02-05 05:06:13 +000031 Store Bind(Store store, Loc loc, SVal val);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000032 Store Remove(Store St, Loc L);
Zhongxing Xub4a9c612010-02-05 05:06:13 +000033 Store BindCompoundLiteral(Store store, const CompoundLiteralExpr* cl,
34 const LocationContext *LC, SVal v);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000035
36 Store getInitialStore(const LocationContext *InitLoc) {
37 return RBFactory.GetEmptyMap().getRoot();
38 }
39
40 SubRegionMap *getSubRegionMap(const GRState *state);
41
42 SVal getLValueVar(const VarDecl *VD, const LocationContext *LC);
43
44 SVal getLValueString(const StringLiteral* sl);
45 SVal getLValueIvar(const ObjCIvarDecl* decl, SVal base);
46 SVal getLValueField(const FieldDecl* D, SVal Base);
47 SVal getLValueElement(QualType elementType, SVal offset, SVal Base);
48 SVal ArrayToPointer(Loc Array);
49 void RemoveDeadBindings(GRState &state, Stmt* Loc,
50 SymbolReaper& SymReaper,
51 llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
52
Zhongxing Xub4a9c612010-02-05 05:06:13 +000053 Store BindDecl(Store store, const VarRegion *VR, SVal initVal);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000054
Zhongxing Xub4a9c612010-02-05 05:06:13 +000055 Store BindDeclWithNoInit(Store store, const VarRegion *VR);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000056
57 typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols;
58
Zhongxing Xub4a9c612010-02-05 05:06:13 +000059 Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E,
60 unsigned Count, InvalidatedSymbols *IS);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000061
62 void print(Store store, llvm::raw_ostream& Out, const char* nl,
63 const char *sep);
64 void iterBindings(Store store, BindingsHandler& f);
65};
66} // end anonymous namespace
67
68StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) {
69 return new FlatStoreManager(StMgr);
70}
71
Zhongxing Xu576bb922010-02-05 03:01:53 +000072SVal FlatStoreManager::Retrieve(Store store, Loc loc, QualType T) {
Zhongxing Xuc999ed72010-02-04 02:39:47 +000073 return UnknownVal();
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000074}
75
Zhongxing Xub4a9c612010-02-05 05:06:13 +000076Store FlatStoreManager::Bind(Store store, Loc loc, SVal val) {
77 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000078}
79
80Store FlatStoreManager::Remove(Store store, Loc L) {
81 return store;
82}
83
Zhongxing Xub4a9c612010-02-05 05:06:13 +000084Store FlatStoreManager::BindCompoundLiteral(Store store,
85 const CompoundLiteralExpr* cl,
86 const LocationContext *LC,
87 SVal v) {
88 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000089}
90
91
92SubRegionMap *FlatStoreManager::getSubRegionMap(const GRState *state) {
93 return 0;
94}
95
96SVal FlatStoreManager::getLValueVar(const VarDecl *VD,
97 const LocationContext *LC) {
98 return UnknownVal();
99}
100
101SVal FlatStoreManager::getLValueString(const StringLiteral* sl) {
102 return UnknownVal();
103}
104
105SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) {
106 return UnknownVal();
107}
108
109SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) {
110 return UnknownVal();
111}
112
113SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset,
114 SVal Base) {
115 return UnknownVal();
116}
117
118SVal FlatStoreManager::ArrayToPointer(Loc Array) {
119 return Array;
120}
121
122void FlatStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
123 SymbolReaper& SymReaper,
124 llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) {
125}
126
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000127Store FlatStoreManager::BindDecl(Store store, const VarRegion *VR,
128 SVal initVal) {
129 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000130}
131
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000132Store FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR) {
133 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000134}
135
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000136Store FlatStoreManager::InvalidateRegion(Store store, const MemRegion *R,
137 const Expr *E, unsigned Count,
138 InvalidatedSymbols *IS) {
139 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000140}
141
142void FlatStoreManager::print(Store store, llvm::raw_ostream& Out,
143 const char* nl, const char *sep) {
144}
145
146void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) {
147}