Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 1 | //=== 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 | |
| 13 | using namespace clang; |
| 14 | |
| 15 | // The actual store type. |
| 16 | typedef llvm::ImmutableIntervalMap<SVal> BindingVal; |
| 17 | typedef llvm::ImmutableMap<const MemRegion *, BindingVal> RegionBindings; |
| 18 | |
| 19 | namespace { |
| 20 | class FlatStoreManager : public StoreManager { |
| 21 | RegionBindings::Factory RBFactory; |
| 22 | BindingVal::Factory BVFactory; |
| 23 | |
| 24 | public: |
| 25 | FlatStoreManager(GRStateManager &mgr) |
| 26 | : StoreManager(mgr), |
| 27 | RBFactory(mgr.getAllocator()), |
| 28 | BVFactory(mgr.getAllocator()) {} |
| 29 | |
Zhongxing Xu | 576bb92 | 2010-02-05 03:01:53 +0000 | [diff] [blame^] | 30 | SVal Retrieve(Store store, Loc loc, QualType T); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 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 | |
| 72 | StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) { |
| 73 | return new FlatStoreManager(StMgr); |
| 74 | } |
| 75 | |
Zhongxing Xu | 576bb92 | 2010-02-05 03:01:53 +0000 | [diff] [blame^] | 76 | SVal FlatStoreManager::Retrieve(Store store, Loc loc, QualType T) { |
Zhongxing Xu | c999ed7 | 2010-02-04 02:39:47 +0000 | [diff] [blame] | 77 | return UnknownVal(); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | const GRState *FlatStoreManager::Bind(const GRState *state, Loc loc, SVal val) { |
| 81 | return state; |
| 82 | } |
| 83 | |
| 84 | Store FlatStoreManager::Remove(Store store, Loc L) { |
| 85 | return store; |
| 86 | } |
| 87 | |
| 88 | const GRState *FlatStoreManager::BindCompoundLiteral(const GRState *state, |
| 89 | const CompoundLiteralExpr* cl, |
| 90 | const LocationContext *LC, |
| 91 | SVal v) { |
| 92 | return state; |
| 93 | } |
| 94 | |
| 95 | |
| 96 | SubRegionMap *FlatStoreManager::getSubRegionMap(const GRState *state) { |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | SVal FlatStoreManager::getLValueVar(const VarDecl *VD, |
| 101 | const LocationContext *LC) { |
| 102 | return UnknownVal(); |
| 103 | } |
| 104 | |
| 105 | SVal FlatStoreManager::getLValueString(const StringLiteral* sl) { |
| 106 | return UnknownVal(); |
| 107 | } |
| 108 | |
| 109 | SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) { |
| 110 | return UnknownVal(); |
| 111 | } |
| 112 | |
| 113 | SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) { |
| 114 | return UnknownVal(); |
| 115 | } |
| 116 | |
| 117 | SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset, |
| 118 | SVal Base) { |
| 119 | return UnknownVal(); |
| 120 | } |
| 121 | |
| 122 | SVal FlatStoreManager::ArrayToPointer(Loc Array) { |
| 123 | return Array; |
| 124 | } |
| 125 | |
| 126 | void FlatStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc, |
| 127 | SymbolReaper& SymReaper, |
| 128 | llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) { |
| 129 | } |
| 130 | |
| 131 | const GRState *FlatStoreManager::BindDecl(const GRState *state, |
| 132 | const VarRegion *VR, SVal initVal) { |
| 133 | return state; |
| 134 | } |
| 135 | |
| 136 | const GRState *FlatStoreManager::BindDeclWithNoInit(const GRState *state, |
| 137 | const VarRegion *VR) { |
| 138 | return state; |
| 139 | } |
| 140 | |
| 141 | const GRState *FlatStoreManager::InvalidateRegion(const GRState *state, |
| 142 | const MemRegion *R, |
| 143 | const Expr *E, unsigned Count, |
| 144 | InvalidatedSymbols *IS) { |
| 145 | return state; |
| 146 | } |
| 147 | |
| 148 | void FlatStoreManager::print(Store store, llvm::raw_ostream& Out, |
| 149 | const char* nl, const char *sep) { |
| 150 | } |
| 151 | |
| 152 | void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) { |
| 153 | } |