blob: 4622f47877f3c9b612cc5ff6167a133d6ff304ef [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
Zhongxing Xuf5416bd2010-02-05 05:18:47 +000040 SubRegionMap *getSubRegionMap(Store store) {
41 return 0;
42 }
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000043
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);
Zhongxing Xu72119c42010-02-05 05:34:29 +000051 Store RemoveDeadBindings(Store store, Stmt* Loc, SymbolReaper& SymReaper,
52 llvm::SmallVectorImpl<const MemRegion*>& RegionRoots){
53 return store;
54 }
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000055
Zhongxing Xub4a9c612010-02-05 05:06:13 +000056 Store BindDecl(Store store, const VarRegion *VR, SVal initVal);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000057
Zhongxing Xub4a9c612010-02-05 05:06:13 +000058 Store BindDeclWithNoInit(Store store, const VarRegion *VR);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000059
60 typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols;
61
Zhongxing Xub4a9c612010-02-05 05:06:13 +000062 Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E,
63 unsigned Count, InvalidatedSymbols *IS);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000064
65 void print(Store store, llvm::raw_ostream& Out, const char* nl,
66 const char *sep);
67 void iterBindings(Store store, BindingsHandler& f);
68};
69} // end anonymous namespace
70
71StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) {
72 return new FlatStoreManager(StMgr);
73}
74
Zhongxing Xu576bb922010-02-05 03:01:53 +000075SVal FlatStoreManager::Retrieve(Store store, Loc loc, QualType T) {
Zhongxing Xuc999ed72010-02-04 02:39:47 +000076 return UnknownVal();
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000077}
78
Zhongxing Xub4a9c612010-02-05 05:06:13 +000079Store FlatStoreManager::Bind(Store store, Loc loc, SVal val) {
80 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000081}
82
83Store FlatStoreManager::Remove(Store store, Loc L) {
84 return store;
85}
86
Zhongxing Xub4a9c612010-02-05 05:06:13 +000087Store FlatStoreManager::BindCompoundLiteral(Store store,
88 const CompoundLiteralExpr* cl,
89 const LocationContext *LC,
90 SVal v) {
91 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000092}
93
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000094SVal FlatStoreManager::getLValueVar(const VarDecl *VD,
95 const LocationContext *LC) {
96 return UnknownVal();
97}
98
99SVal FlatStoreManager::getLValueString(const StringLiteral* sl) {
100 return UnknownVal();
101}
102
103SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) {
104 return UnknownVal();
105}
106
107SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) {
108 return UnknownVal();
109}
110
111SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset,
112 SVal Base) {
113 return UnknownVal();
114}
115
116SVal FlatStoreManager::ArrayToPointer(Loc Array) {
117 return Array;
118}
119
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000120Store FlatStoreManager::BindDecl(Store store, const VarRegion *VR,
121 SVal initVal) {
122 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000123}
124
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000125Store FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR) {
126 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000127}
128
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000129Store FlatStoreManager::InvalidateRegion(Store store, const MemRegion *R,
130 const Expr *E, unsigned Count,
131 InvalidatedSymbols *IS) {
132 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000133}
134
135void FlatStoreManager::print(Store store, llvm::raw_ostream& Out,
136 const char* nl, const char *sep) {
137}
138
139void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) {
140}