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 | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 31 | Store Bind(Store store, Loc loc, SVal val); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 32 | Store Remove(Store St, Loc L); |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 33 | Store BindCompoundLiteral(Store store, const CompoundLiteralExpr* cl, |
| 34 | const LocationContext *LC, SVal v); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 35 | |
| 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 Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 53 | Store BindDecl(Store store, const VarRegion *VR, SVal initVal); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 54 | |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 55 | Store BindDeclWithNoInit(Store store, const VarRegion *VR); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 56 | |
| 57 | typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols; |
| 58 | |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 59 | Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E, |
| 60 | unsigned Count, InvalidatedSymbols *IS); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 61 | |
| 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 | |
| 68 | StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) { |
| 69 | return new FlatStoreManager(StMgr); |
| 70 | } |
| 71 | |
Zhongxing Xu | 576bb92 | 2010-02-05 03:01:53 +0000 | [diff] [blame] | 72 | SVal FlatStoreManager::Retrieve(Store store, Loc loc, QualType T) { |
Zhongxing Xu | c999ed7 | 2010-02-04 02:39:47 +0000 | [diff] [blame] | 73 | return UnknownVal(); |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 76 | Store FlatStoreManager::Bind(Store store, Loc loc, SVal val) { |
| 77 | return store; |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | Store FlatStoreManager::Remove(Store store, Loc L) { |
| 81 | return store; |
| 82 | } |
| 83 | |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 84 | Store FlatStoreManager::BindCompoundLiteral(Store store, |
| 85 | const CompoundLiteralExpr* cl, |
| 86 | const LocationContext *LC, |
| 87 | SVal v) { |
| 88 | return store; |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | |
| 92 | SubRegionMap *FlatStoreManager::getSubRegionMap(const GRState *state) { |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | SVal FlatStoreManager::getLValueVar(const VarDecl *VD, |
| 97 | const LocationContext *LC) { |
| 98 | return UnknownVal(); |
| 99 | } |
| 100 | |
| 101 | SVal FlatStoreManager::getLValueString(const StringLiteral* sl) { |
| 102 | return UnknownVal(); |
| 103 | } |
| 104 | |
| 105 | SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) { |
| 106 | return UnknownVal(); |
| 107 | } |
| 108 | |
| 109 | SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) { |
| 110 | return UnknownVal(); |
| 111 | } |
| 112 | |
| 113 | SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset, |
| 114 | SVal Base) { |
| 115 | return UnknownVal(); |
| 116 | } |
| 117 | |
| 118 | SVal FlatStoreManager::ArrayToPointer(Loc Array) { |
| 119 | return Array; |
| 120 | } |
| 121 | |
| 122 | void FlatStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc, |
| 123 | SymbolReaper& SymReaper, |
| 124 | llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) { |
| 125 | } |
| 126 | |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 127 | Store FlatStoreManager::BindDecl(Store store, const VarRegion *VR, |
| 128 | SVal initVal) { |
| 129 | return store; |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 132 | Store FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR) { |
| 133 | return store; |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 134 | } |
| 135 | |
Zhongxing Xu | b4a9c61 | 2010-02-05 05:06:13 +0000 | [diff] [blame] | 136 | Store FlatStoreManager::InvalidateRegion(Store store, const MemRegion *R, |
| 137 | const Expr *E, unsigned Count, |
| 138 | InvalidatedSymbols *IS) { |
| 139 | return store; |
Zhongxing Xu | 5d26bc0 | 2010-02-03 09:10:32 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | void FlatStoreManager::print(Store store, llvm::raw_ostream& Out, |
| 143 | const char* nl, const char *sep) { |
| 144 | } |
| 145 | |
| 146 | void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) { |
| 147 | } |