blob: c4f37dff658233f53b8043305dceb3fdd0da17de [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);
51 void RemoveDeadBindings(GRState &state, Stmt* Loc,
52 SymbolReaper& SymReaper,
53 llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
54
Zhongxing Xub4a9c612010-02-05 05:06:13 +000055 Store BindDecl(Store store, const VarRegion *VR, SVal initVal);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000056
Zhongxing Xub4a9c612010-02-05 05:06:13 +000057 Store BindDeclWithNoInit(Store store, const VarRegion *VR);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000058
59 typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols;
60
Zhongxing Xub4a9c612010-02-05 05:06:13 +000061 Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E,
62 unsigned Count, InvalidatedSymbols *IS);
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000063
64 void print(Store store, llvm::raw_ostream& Out, const char* nl,
65 const char *sep);
66 void iterBindings(Store store, BindingsHandler& f);
67};
68} // end anonymous namespace
69
70StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) {
71 return new FlatStoreManager(StMgr);
72}
73
Zhongxing Xu576bb922010-02-05 03:01:53 +000074SVal FlatStoreManager::Retrieve(Store store, Loc loc, QualType T) {
Zhongxing Xuc999ed72010-02-04 02:39:47 +000075 return UnknownVal();
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000076}
77
Zhongxing Xub4a9c612010-02-05 05:06:13 +000078Store FlatStoreManager::Bind(Store store, Loc loc, SVal val) {
79 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000080}
81
82Store FlatStoreManager::Remove(Store store, Loc L) {
83 return store;
84}
85
Zhongxing Xub4a9c612010-02-05 05:06:13 +000086Store FlatStoreManager::BindCompoundLiteral(Store store,
87 const CompoundLiteralExpr* cl,
88 const LocationContext *LC,
89 SVal v) {
90 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000091}
92
Zhongxing Xu5d26bc02010-02-03 09:10:32 +000093SVal FlatStoreManager::getLValueVar(const VarDecl *VD,
94 const LocationContext *LC) {
95 return UnknownVal();
96}
97
98SVal FlatStoreManager::getLValueString(const StringLiteral* sl) {
99 return UnknownVal();
100}
101
102SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) {
103 return UnknownVal();
104}
105
106SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) {
107 return UnknownVal();
108}
109
110SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset,
111 SVal Base) {
112 return UnknownVal();
113}
114
115SVal FlatStoreManager::ArrayToPointer(Loc Array) {
116 return Array;
117}
118
119void FlatStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
120 SymbolReaper& SymReaper,
121 llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) {
122}
123
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000124Store FlatStoreManager::BindDecl(Store store, const VarRegion *VR,
125 SVal initVal) {
126 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000127}
128
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000129Store FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR) {
130 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000131}
132
Zhongxing Xub4a9c612010-02-05 05:06:13 +0000133Store FlatStoreManager::InvalidateRegion(Store store, const MemRegion *R,
134 const Expr *E, unsigned Count,
135 InvalidatedSymbols *IS) {
136 return store;
Zhongxing Xu5d26bc02010-02-03 09:10:32 +0000137}
138
139void FlatStoreManager::print(Store store, llvm::raw_ostream& Out,
140 const char* nl, const char *sep) {
141}
142
143void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) {
144}