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