Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 1 | //= GRState*cpp - Path-Sens. "State" for tracking valuues -----*- C++ -*--=// |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 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 | // |
Ted Kremenek | 2dabd43 | 2008-12-05 02:27:51 +0000 | [diff] [blame^] | 10 | // This file defines SymbolRef, ExprBindKey, and GRState* |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Ted Kremenek | e7aa9a1 | 2008-08-17 02:59:30 +0000 | [diff] [blame] | 14 | #include "clang/Analysis/PathSensitive/GRStateTrait.h" |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 15 | #include "clang/Analysis/PathSensitive/GRState.h" |
Ted Kremenek | 729a9a2 | 2008-07-17 23:15:45 +0000 | [diff] [blame] | 16 | #include "clang/Analysis/PathSensitive/GRTransferFuncs.h" |
Ted Kremenek | 05125f1 | 2008-08-27 23:13:01 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/SmallSet.h" |
Chris Lattner | 405674c | 2008-08-23 22:23:37 +0000 | [diff] [blame] | 18 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | 05125f1 | 2008-08-27 23:13:01 +0000 | [diff] [blame] | 19 | |
Ted Kremenek | f66ea2cd | 2008-02-04 21:59:22 +0000 | [diff] [blame] | 20 | using namespace clang; |
| 21 | |
Ted Kremenek | 05125f1 | 2008-08-27 23:13:01 +0000 | [diff] [blame] | 22 | // Give the vtable for ConstraintManager somewhere to live. |
| 23 | ConstraintManager::~ConstraintManager() {} |
| 24 | |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 25 | GRStateManager::~GRStateManager() { |
| 26 | for (std::vector<GRState::Printer*>::iterator I=Printers.begin(), |
| 27 | E=Printers.end(); I!=E; ++I) |
| 28 | delete *I; |
| 29 | |
| 30 | for (GDMContextsTy::iterator I=GDMContexts.begin(), E=GDMContexts.end(); |
| 31 | I!=E; ++I) |
| 32 | I->second.second(I->second.first); |
| 33 | } |
| 34 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 35 | const GRState* |
Ted Kremenek | 2ed14be | 2008-12-05 00:47:52 +0000 | [diff] [blame] | 36 | GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc, |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 37 | const LiveVariables& Liveness, |
| 38 | DeadSymbolsTy& DSymbols) { |
Ted Kremenek | b87d909 | 2008-02-08 19:17:19 +0000 | [diff] [blame] | 39 | |
| 40 | // This code essentially performs a "mark-and-sweep" of the VariableBindings. |
| 41 | // The roots are any Block-level exprs and Decls that our liveness algorithm |
| 42 | // tells us are live. We then see what Decls they may reference, and keep |
| 43 | // those around. This code more than likely can be made faster, and the |
| 44 | // frequency of which this method is called should be experimented with |
Ted Kremenek | 9e24049 | 2008-10-04 05:50:14 +0000 | [diff] [blame] | 45 | // for optimum performance. |
| 46 | llvm::SmallVector<const MemRegion*, 10> RegionRoots; |
Ted Kremenek | f59bf48 | 2008-07-17 18:38:48 +0000 | [diff] [blame] | 47 | StoreManager::LiveSymbolsTy LSymbols; |
Ted Kremenek | 2ed14be | 2008-12-05 00:47:52 +0000 | [diff] [blame] | 48 | GRState NewState = *state; |
Ted Kremenek | f59bf48 | 2008-07-17 18:38:48 +0000 | [diff] [blame] | 49 | |
Ted Kremenek | 2ed14be | 2008-12-05 00:47:52 +0000 | [diff] [blame] | 50 | NewState.Env = EnvMgr.RemoveDeadBindings(NewState.Env, Loc, Liveness, |
| 51 | RegionRoots, LSymbols); |
Ted Kremenek | 016f52f | 2008-02-08 21:10:02 +0000 | [diff] [blame] | 52 | |
Ted Kremenek | f59bf48 | 2008-07-17 18:38:48 +0000 | [diff] [blame] | 53 | // Clean up the store. |
| 54 | DSymbols.clear(); |
Ted Kremenek | 2ed14be | 2008-12-05 00:47:52 +0000 | [diff] [blame] | 55 | NewState.St = StoreMgr->RemoveDeadBindings(&NewState, Loc, Liveness, |
| 56 | RegionRoots, LSymbols, DSymbols); |
Ted Kremenek | ffdbefd | 2008-08-17 03:10:22 +0000 | [diff] [blame] | 57 | |
Ted Kremenek | 2ed14be | 2008-12-05 00:47:52 +0000 | [diff] [blame] | 58 | return ConstraintMgr->RemoveDeadBindings(getPersistentState(NewState), |
Zhongxing Xu | 39cfed3 | 2008-08-29 14:52:36 +0000 | [diff] [blame] | 59 | LSymbols, DSymbols); |
Ted Kremenek | b87d909 | 2008-02-08 19:17:19 +0000 | [diff] [blame] | 60 | } |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 61 | |
Zhongxing Xu | 8cd5aae | 2008-10-30 05:33:54 +0000 | [diff] [blame] | 62 | const GRState* GRStateManager::BindLoc(const GRState* St, Loc LV, SVal V) { |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 63 | |
Ted Kremenek | 4323a57 | 2008-07-10 22:03:41 +0000 | [diff] [blame] | 64 | Store OldStore = St->getStore(); |
Zhongxing Xu | 8485ec6 | 2008-10-21 06:27:32 +0000 | [diff] [blame] | 65 | Store NewStore = StoreMgr->Bind(OldStore, LV, V); |
Ted Kremenek | 3271f8d | 2008-02-07 04:16:04 +0000 | [diff] [blame] | 66 | |
Ted Kremenek | 4323a57 | 2008-07-10 22:03:41 +0000 | [diff] [blame] | 67 | if (NewStore == OldStore) |
| 68 | return St; |
Ted Kremenek | 692416c | 2008-02-18 22:57:02 +0000 | [diff] [blame] | 69 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 70 | GRState NewSt = *St; |
Ted Kremenek | 4323a57 | 2008-07-10 22:03:41 +0000 | [diff] [blame] | 71 | NewSt.St = NewStore; |
| 72 | return getPersistentState(NewSt); |
Ted Kremenek | f66ea2cd | 2008-02-04 21:59:22 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Zhongxing Xu | 8b2e05d | 2008-10-29 02:34:02 +0000 | [diff] [blame] | 75 | const GRState* GRStateManager::BindDecl(const GRState* St, const VarDecl* VD, |
Ted Kremenek | d493163 | 2008-11-12 19:21:30 +0000 | [diff] [blame] | 76 | SVal* InitVal, unsigned Count) { |
Zhongxing Xu | bbe8ff4 | 2008-08-21 22:34:01 +0000 | [diff] [blame] | 77 | Store OldStore = St->getStore(); |
Ted Kremenek | d493163 | 2008-11-12 19:21:30 +0000 | [diff] [blame] | 78 | Store NewStore = StoreMgr->BindDecl(OldStore, VD, InitVal, Count); |
Zhongxing Xu | bbe8ff4 | 2008-08-21 22:34:01 +0000 | [diff] [blame] | 79 | |
Zhongxing Xu | bbe8ff4 | 2008-08-21 22:34:01 +0000 | [diff] [blame] | 80 | if (NewStore == OldStore) |
| 81 | return St; |
Ted Kremenek | e53c069 | 2008-08-23 00:50:55 +0000 | [diff] [blame] | 82 | |
Zhongxing Xu | bbe8ff4 | 2008-08-21 22:34:01 +0000 | [diff] [blame] | 83 | GRState NewSt = *St; |
| 84 | NewSt.St = NewStore; |
| 85 | return getPersistentState(NewSt); |
| 86 | } |
| 87 | |
Ted Kremenek | 4f09027 | 2008-10-27 21:54:31 +0000 | [diff] [blame] | 88 | /// BindCompoundLiteral - Return the store that has the bindings currently |
| 89 | /// in 'store' plus the bindings for the CompoundLiteral. 'R' is the region |
| 90 | /// for the compound literal and 'BegInit' and 'EndInit' represent an |
| 91 | /// array of initializer values. |
| 92 | const GRState* |
| 93 | GRStateManager::BindCompoundLiteral(const GRState* state, |
Zhongxing Xu | f22679e | 2008-11-07 10:38:33 +0000 | [diff] [blame] | 94 | const CompoundLiteralExpr* CL, SVal ILV) { |
Ted Kremenek | 4f09027 | 2008-10-27 21:54:31 +0000 | [diff] [blame] | 95 | |
| 96 | Store oldStore = state->getStore(); |
Zhongxing Xu | f22679e | 2008-11-07 10:38:33 +0000 | [diff] [blame] | 97 | Store newStore = StoreMgr->BindCompoundLiteral(oldStore, CL, ILV); |
Ted Kremenek | 4f09027 | 2008-10-27 21:54:31 +0000 | [diff] [blame] | 98 | |
| 99 | if (newStore == oldStore) |
| 100 | return state; |
| 101 | |
| 102 | GRState newState = *state; |
| 103 | newState.St = newStore; |
| 104 | return getPersistentState(newState); |
| 105 | } |
| 106 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 107 | const GRState* GRStateManager::Unbind(const GRState* St, Loc LV) { |
Ted Kremenek | 4323a57 | 2008-07-10 22:03:41 +0000 | [diff] [blame] | 108 | Store OldStore = St->getStore(); |
Zhongxing Xu | 6d69b5d | 2008-10-16 06:09:51 +0000 | [diff] [blame] | 109 | Store NewStore = StoreMgr->Remove(OldStore, LV); |
Ted Kremenek | 4323a57 | 2008-07-10 22:03:41 +0000 | [diff] [blame] | 110 | |
| 111 | if (NewStore == OldStore) |
| 112 | return St; |
| 113 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 114 | GRState NewSt = *St; |
Ted Kremenek | 4323a57 | 2008-07-10 22:03:41 +0000 | [diff] [blame] | 115 | NewSt.St = NewStore; |
| 116 | return getPersistentState(NewSt); |
| 117 | } |
| 118 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 119 | const GRState* GRStateManager::getInitialState() { |
Ted Kremenek | 5a7b382 | 2008-02-26 23:37:01 +0000 | [diff] [blame] | 120 | |
Ted Kremenek | caa3724 | 2008-08-19 16:51:45 +0000 | [diff] [blame] | 121 | GRState StateImpl(EnvMgr.getInitialEnvironment(), |
Zhongxing Xu | 6d69b5d | 2008-10-16 06:09:51 +0000 | [diff] [blame] | 122 | StoreMgr->getInitialStore(), |
Ted Kremenek | ffdbefd | 2008-08-17 03:10:22 +0000 | [diff] [blame] | 123 | GDMFactory.GetEmptyMap()); |
Ted Kremenek | caa3724 | 2008-08-19 16:51:45 +0000 | [diff] [blame] | 124 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 125 | return getPersistentState(StateImpl); |
| 126 | } |
| 127 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 128 | const GRState* GRStateManager::getPersistentState(GRState& State) { |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 129 | |
| 130 | llvm::FoldingSetNodeID ID; |
| 131 | State.Profile(ID); |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 132 | void* InsertPos; |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 133 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 134 | if (GRState* I = StateSet.FindNodeOrInsertPos(ID, InsertPos)) |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 135 | return I; |
| 136 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 137 | GRState* I = (GRState*) Alloc.Allocate<GRState>(); |
| 138 | new (I) GRState(State); |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 139 | StateSet.InsertNode(I, InsertPos); |
| 140 | return I; |
| 141 | } |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 142 | |
Ted Kremenek | 59894f9 | 2008-03-04 18:30:35 +0000 | [diff] [blame] | 143 | |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 144 | //===----------------------------------------------------------------------===// |
| 145 | // State pretty-printing. |
| 146 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 461f977 | 2008-03-11 18:57:24 +0000 | [diff] [blame] | 147 | |
Ted Kremenek | a622d8c | 2008-08-19 22:24:03 +0000 | [diff] [blame] | 148 | void GRState::print(std::ostream& Out, StoreManager& StoreMgr, |
Zhongxing Xu | 39cfed3 | 2008-08-29 14:52:36 +0000 | [diff] [blame] | 149 | ConstraintManager& ConstraintMgr, |
Ted Kremenek | a622d8c | 2008-08-19 22:24:03 +0000 | [diff] [blame] | 150 | Printer** Beg, Printer** End, |
Ted Kremenek | ae6814e | 2008-08-13 21:24:49 +0000 | [diff] [blame] | 151 | const char* nl, const char* sep) const { |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 152 | |
Ted Kremenek | a622d8c | 2008-08-19 22:24:03 +0000 | [diff] [blame] | 153 | // Print the store. |
| 154 | StoreMgr.print(getStore(), Out, nl, sep); |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 155 | |
| 156 | // Print Subexpression bindings. |
Ted Kremenek | a622d8c | 2008-08-19 22:24:03 +0000 | [diff] [blame] | 157 | bool isFirst = true; |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 158 | |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 159 | for (seb_iterator I = seb_begin(), E = seb_end(); I != E; ++I) { |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 160 | |
| 161 | if (isFirst) { |
Ted Kremenek | 59894f9 | 2008-03-04 18:30:35 +0000 | [diff] [blame] | 162 | Out << nl << nl << "Sub-Expressions:" << nl; |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 163 | isFirst = false; |
| 164 | } |
Ted Kremenek | 59894f9 | 2008-03-04 18:30:35 +0000 | [diff] [blame] | 165 | else { Out << nl; } |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 166 | |
| 167 | Out << " (" << (void*) I.getKey() << ") "; |
Ted Kremenek | a95d375 | 2008-09-13 05:16:45 +0000 | [diff] [blame] | 168 | llvm::raw_os_ostream OutS(Out); |
| 169 | I.getKey()->printPretty(OutS); |
| 170 | OutS.flush(); |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 171 | Out << " : "; |
| 172 | I.getData().print(Out); |
| 173 | } |
| 174 | |
| 175 | // Print block-expression bindings. |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 176 | isFirst = true; |
| 177 | |
Ted Kremenek | aa1c4e5 | 2008-02-21 18:02:17 +0000 | [diff] [blame] | 178 | for (beb_iterator I = beb_begin(), E = beb_end(); I != E; ++I) { |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 179 | |
| 180 | if (isFirst) { |
Ted Kremenek | 59894f9 | 2008-03-04 18:30:35 +0000 | [diff] [blame] | 181 | Out << nl << nl << "Block-level Expressions:" << nl; |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 182 | isFirst = false; |
| 183 | } |
Ted Kremenek | 59894f9 | 2008-03-04 18:30:35 +0000 | [diff] [blame] | 184 | else { Out << nl; } |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 185 | |
| 186 | Out << " (" << (void*) I.getKey() << ") "; |
Ted Kremenek | a95d375 | 2008-09-13 05:16:45 +0000 | [diff] [blame] | 187 | llvm::raw_os_ostream OutS(Out); |
| 188 | I.getKey()->printPretty(OutS); |
| 189 | OutS.flush(); |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 190 | Out << " : "; |
| 191 | I.getData().print(Out); |
| 192 | } |
| 193 | |
Zhongxing Xu | 39cfed3 | 2008-08-29 14:52:36 +0000 | [diff] [blame] | 194 | ConstraintMgr.print(this, Out, nl, sep); |
Ted Kremenek | 461f977 | 2008-03-11 18:57:24 +0000 | [diff] [blame] | 195 | |
Ted Kremenek | ae6814e | 2008-08-13 21:24:49 +0000 | [diff] [blame] | 196 | // Print checker-specific data. |
| 197 | for ( ; Beg != End ; ++Beg) (*Beg)->Print(Out, this, nl, sep); |
Ted Kremenek | e7d2211 | 2008-02-11 19:21:59 +0000 | [diff] [blame] | 198 | } |
Ted Kremenek | 729a9a2 | 2008-07-17 23:15:45 +0000 | [diff] [blame] | 199 | |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 200 | void GRStateRef::printDOT(std::ostream& Out) const { |
| 201 | print(Out, "\\l", "\\|"); |
| 202 | } |
| 203 | |
| 204 | void GRStateRef::printStdErr() const { |
| 205 | print(*llvm::cerr); |
| 206 | } |
| 207 | |
| 208 | void GRStateRef::print(std::ostream& Out, const char* nl, const char* sep)const{ |
| 209 | GRState::Printer **beg = Mgr->Printers.empty() ? 0 : &Mgr->Printers[0]; |
| 210 | GRState::Printer **end = !beg ? 0 : beg + Mgr->Printers.size(); |
Zhongxing Xu | 6d69b5d | 2008-10-16 06:09:51 +0000 | [diff] [blame] | 211 | St->print(Out, *Mgr->StoreMgr, *Mgr->ConstraintMgr, beg, end, nl, sep); |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 212 | } |
| 213 | |
Ted Kremenek | 72cd17f | 2008-08-14 21:16:54 +0000 | [diff] [blame] | 214 | //===----------------------------------------------------------------------===// |
| 215 | // Generic Data Map. |
| 216 | //===----------------------------------------------------------------------===// |
| 217 | |
| 218 | void* const* GRState::FindGDM(void* K) const { |
| 219 | return GDM.lookup(K); |
| 220 | } |
| 221 | |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 222 | void* |
| 223 | GRStateManager::FindGDMContext(void* K, |
| 224 | void* (*CreateContext)(llvm::BumpPtrAllocator&), |
| 225 | void (*DeleteContext)(void*)) { |
| 226 | |
| 227 | std::pair<void*, void (*)(void*)>& p = GDMContexts[K]; |
| 228 | if (!p.first) { |
| 229 | p.first = CreateContext(Alloc); |
| 230 | p.second = DeleteContext; |
| 231 | } |
| 232 | |
| 233 | return p.first; |
| 234 | } |
| 235 | |
Zhongxing Xu | 4230da6 | 2008-11-03 05:18:34 +0000 | [diff] [blame] | 236 | const GRState* GRStateManager::addGDM(const GRState* St, void* Key, void* Data){ |
Ted Kremenek | 72cd17f | 2008-08-14 21:16:54 +0000 | [diff] [blame] | 237 | GRState::GenericDataMap M1 = St->getGDM(); |
| 238 | GRState::GenericDataMap M2 = GDMFactory.Add(M1, Key, Data); |
| 239 | |
| 240 | if (M1 == M2) |
| 241 | return St; |
| 242 | |
| 243 | GRState NewSt = *St; |
| 244 | NewSt.GDM = M2; |
| 245 | return getPersistentState(NewSt); |
| 246 | } |
Ted Kremenek | 584def7 | 2008-07-22 00:46:16 +0000 | [diff] [blame] | 247 | |
| 248 | //===----------------------------------------------------------------------===// |
| 249 | // Queries. |
| 250 | //===----------------------------------------------------------------------===// |
| 251 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 252 | bool GRStateManager::isEqual(const GRState* state, Expr* Ex, |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 253 | const llvm::APSInt& Y) { |
| 254 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 255 | SVal V = GetSVal(state, Ex); |
Ted Kremenek | 584def7 | 2008-07-22 00:46:16 +0000 | [diff] [blame] | 256 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 257 | if (loc::ConcreteInt* X = dyn_cast<loc::ConcreteInt>(&V)) |
Ted Kremenek | 584def7 | 2008-07-22 00:46:16 +0000 | [diff] [blame] | 258 | return X->getValue() == Y; |
| 259 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 260 | if (nonloc::ConcreteInt* X = dyn_cast<nonloc::ConcreteInt>(&V)) |
Ted Kremenek | 584def7 | 2008-07-22 00:46:16 +0000 | [diff] [blame] | 261 | return X->getValue() == Y; |
| 262 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 263 | if (nonloc::SymbolVal* X = dyn_cast<nonloc::SymbolVal>(&V)) |
Zhongxing Xu | 39cfed3 | 2008-08-29 14:52:36 +0000 | [diff] [blame] | 264 | return ConstraintMgr->isEqual(state, X->getSymbol(), Y); |
Ted Kremenek | 584def7 | 2008-07-22 00:46:16 +0000 | [diff] [blame] | 265 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 266 | if (loc::SymbolVal* X = dyn_cast<loc::SymbolVal>(&V)) |
Zhongxing Xu | 39cfed3 | 2008-08-29 14:52:36 +0000 | [diff] [blame] | 267 | return ConstraintMgr->isEqual(state, X->getSymbol(), Y); |
Ted Kremenek | 584def7 | 2008-07-22 00:46:16 +0000 | [diff] [blame] | 268 | |
| 269 | return false; |
| 270 | } |
| 271 | |
Ted Kremenek | 1c72ef0 | 2008-08-16 00:49:49 +0000 | [diff] [blame] | 272 | bool GRStateManager::isEqual(const GRState* state, Expr* Ex, uint64_t x) { |
Ted Kremenek | 584def7 | 2008-07-22 00:46:16 +0000 | [diff] [blame] | 273 | return isEqual(state, Ex, BasicVals.getValue(x, Ex->getType())); |
| 274 | } |
Ted Kremenek | 7360fda | 2008-09-18 23:09:54 +0000 | [diff] [blame] | 275 | |
| 276 | //===----------------------------------------------------------------------===// |
| 277 | // Persistent values for indexing into the Generic Data Map. |
| 278 | |
| 279 | int GRState::NullDerefTag::TagInt = 0; |
| 280 | |