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