blob: 69470bbbb28003d3f65b5a03b8cdf81a1bcdd513 [file] [log] [blame]
Ted Kremenek53ba0b62009-06-24 23:06:47 +00001//= GRState.cpp - Path-Sensitive "State" for tracking values -----*- C++ -*--=//
Ted Kremenek9153f732008-02-05 07:17:49 +00002//
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 Kremenek53ba0b62009-06-24 23:06:47 +000010// This file implements GRState and GRStateManager.
Ted Kremenek9153f732008-02-05 07:17:49 +000011//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramer5e2d2c22010-03-27 21:19:47 +000014#include "clang/Analysis/CFG.h"
Ted Kremenek1309f9a2010-01-25 04:41:41 +000015#include "clang/Checker/PathSensitive/GRStateTrait.h"
16#include "clang/Checker/PathSensitive/GRState.h"
17#include "clang/Checker/PathSensitive/GRTransferFuncs.h"
Chris Lattner405674c2008-08-23 22:23:37 +000018#include "llvm/Support/raw_ostream.h"
Ted Kremenek05125f12008-08-27 23:13:01 +000019
Ted Kremenekf66ea2cd2008-02-04 21:59:22 +000020using namespace clang;
21
Ted Kremenek05125f12008-08-27 23:13:01 +000022// Give the vtable for ConstraintManager somewhere to live.
Ted Kremenek53ba0b62009-06-24 23:06:47 +000023// FIXME: Move this elsewhere.
Ted Kremenek05125f12008-08-27 23:13:01 +000024ConstraintManager::~ConstraintManager() {}
25
Ted Kremenek1c72ef02008-08-16 00:49:49 +000026GRStateManager::~GRStateManager() {
27 for (std::vector<GRState::Printer*>::iterator I=Printers.begin(),
28 E=Printers.end(); I!=E; ++I)
29 delete *I;
Mike Stump1eb44332009-09-09 15:08:12 +000030
Ted Kremenek1c72ef02008-08-16 00:49:49 +000031 for (GDMContextsTy::iterator I=GDMContexts.begin(), E=GDMContexts.end();
32 I!=E; ++I)
33 I->second.second(I->second.first);
34}
35
Ted Kremenek4adc81e2008-08-13 04:27:00 +000036const GRState*
Jordy Rose7dadf792010-07-01 20:09:55 +000037GRStateManager::RemoveDeadBindings(const GRState* state,
Zhongxing Xu17ddf1c2010-03-17 03:35:08 +000038 const StackFrameContext *LCtx,
Ted Kremenek241677a2009-01-21 22:26:05 +000039 SymbolReaper& SymReaper) {
40
Ted Kremenekb87d9092008-02-08 19:17:19 +000041 // This code essentially performs a "mark-and-sweep" of the VariableBindings.
42 // The roots are any Block-level exprs and Decls that our liveness algorithm
43 // tells us are live. We then see what Decls they may reference, and keep
44 // those around. This code more than likely can be made faster, and the
45 // frequency of which this method is called should be experimented with
Ted Kremenek9e240492008-10-04 05:50:14 +000046 // for optimum performance.
47 llvm::SmallVector<const MemRegion*, 10> RegionRoots;
Ted Kremenek2ed14be2008-12-05 00:47:52 +000048 GRState NewState = *state;
Ted Kremenekf59bf482008-07-17 18:38:48 +000049
Jordy Rose7dadf792010-07-01 20:09:55 +000050 NewState.Env = EnvMgr.RemoveDeadBindings(NewState.Env, SymReaper,
Ted Kremenek5dc27462009-03-03 02:51:43 +000051 state, RegionRoots);
Ted Kremenek016f52f2008-02-08 21:10:02 +000052
Ted Kremenekf59bf482008-07-17 18:38:48 +000053 // Clean up the store.
Jordy Rose7dadf792010-07-01 20:09:55 +000054 const GRState *s = StoreMgr->RemoveDeadBindings(NewState, LCtx,
Zhongxing Xu95798982010-05-26 03:27:35 +000055 SymReaper, RegionRoots);
Ted Kremenekffdbefd2008-08-17 03:10:22 +000056
Zhongxing Xu95798982010-05-26 03:27:35 +000057 return ConstraintMgr->RemoveDeadBindings(s, SymReaper);
Ted Kremenekb87d9092008-02-08 19:17:19 +000058}
Ted Kremenek862d5bb2008-02-06 00:54:14 +000059
Zhongxing Xu2ce43c82010-07-22 13:52:13 +000060const GRState *GRStateManager::MarshalState(const GRState *state,
Zhongxing Xud5ef7b22010-07-23 05:55:01 +000061 const StackFrameContext *InitLoc) {
Zhongxing Xu2ce43c82010-07-22 13:52:13 +000062 // make up an empty state for now.
63 GRState State(this,
64 EnvMgr.getInitialEnvironment(),
65 StoreMgr->getInitialStore(InitLoc),
66 GDMFactory.GetEmptyMap());
67
68 return getPersistentState(State);
69}
70
Ted Kremenek76500d02009-06-23 20:38:51 +000071const GRState *GRState::unbindLoc(Loc LV) const {
72 Store OldStore = getStore();
Ted Kremenek0fb0bc42009-08-27 01:39:13 +000073 Store NewStore = getStateManager().StoreMgr->Remove(OldStore, LV);
Mike Stump1eb44332009-09-09 15:08:12 +000074
Ted Kremenek4323a572008-07-10 22:03:41 +000075 if (NewStore == OldStore)
Ted Kremenek76500d02009-06-23 20:38:51 +000076 return this;
Mike Stump1eb44332009-09-09 15:08:12 +000077
Ted Kremenek76500d02009-06-23 20:38:51 +000078 GRState NewSt = *this;
Ted Kremenek4323a572008-07-10 22:03:41 +000079 NewSt.St = NewStore;
Mike Stump1eb44332009-09-09 15:08:12 +000080 return getStateManager().getPersistentState(NewSt);
Ted Kremenek4323a572008-07-10 22:03:41 +000081}
82
Ted Kremenek13976632010-02-08 16:18:51 +000083SVal GRState::getSValAsScalarOrLoc(const MemRegion *R) const {
Ted Kremenek233e9132009-06-24 22:15:30 +000084 // We only want to do fetches from regions that we can actually bind
85 // values. For example, SymbolicRegions of type 'id<...>' cannot
86 // have direct bindings (but their can be bindings on their subregions).
87 if (!R->isBoundable())
88 return UnknownVal();
89
90 if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
Ted Kremenek0fb0bc42009-08-27 01:39:13 +000091 QualType T = TR->getValueType(getStateManager().getContext());
Ted Kremenek233e9132009-06-24 22:15:30 +000092 if (Loc::IsLocType(T) || T->isIntegerType())
Ted Kremenek13976632010-02-08 16:18:51 +000093 return getSVal(R);
Ted Kremenek233e9132009-06-24 22:15:30 +000094 }
95
96 return UnknownVal();
97}
98
Ted Kremenek4f596c22009-06-27 00:24:54 +000099
Ted Kremenek8e029342009-08-27 22:17:37 +0000100const GRState *GRState::BindExpr(const Stmt* Ex, SVal V, bool Invalidate) const{
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000101 Environment NewEnv = getStateManager().EnvMgr.BindExpr(Env, Ex, V,
Mike Stump1eb44332009-09-09 15:08:12 +0000102 Invalidate);
Ted Kremenek4f596c22009-06-27 00:24:54 +0000103 if (NewEnv == Env)
104 return this;
Ted Kremenek6d2c6572009-08-27 22:15:20 +0000105
Ted Kremenek4f596c22009-06-27 00:24:54 +0000106 GRState NewSt = *this;
107 NewSt.Env = NewEnv;
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000108 return getStateManager().getPersistentState(NewSt);
Ted Kremenek4f596c22009-06-27 00:24:54 +0000109}
110
Zhongxing Xu17fd8632009-08-17 06:19:58 +0000111const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
Ted Kremenek6d2c6572009-08-27 22:15:20 +0000112 GRState State(this,
Zhongxing Xuc179a7f2010-03-05 04:45:36 +0000113 EnvMgr.getInitialEnvironment(),
Zhongxing Xu17fd8632009-08-17 06:19:58 +0000114 StoreMgr->getInitialStore(InitLoc),
115 GDMFactory.GetEmptyMap());
Ted Kremenekcaa37242008-08-19 16:51:45 +0000116
Zhongxing Xu17fd8632009-08-17 06:19:58 +0000117 return getPersistentState(State);
Ted Kremenek9153f732008-02-05 07:17:49 +0000118}
119
Ted Kremenek4adc81e2008-08-13 04:27:00 +0000120const GRState* GRStateManager::getPersistentState(GRState& State) {
Mike Stump1eb44332009-09-09 15:08:12 +0000121
Ted Kremenek9153f732008-02-05 07:17:49 +0000122 llvm::FoldingSetNodeID ID;
Mike Stump1eb44332009-09-09 15:08:12 +0000123 State.Profile(ID);
Ted Kremeneke7d22112008-02-11 19:21:59 +0000124 void* InsertPos;
Mike Stump1eb44332009-09-09 15:08:12 +0000125
Ted Kremenek4adc81e2008-08-13 04:27:00 +0000126 if (GRState* I = StateSet.FindNodeOrInsertPos(ID, InsertPos))
Ted Kremenek9153f732008-02-05 07:17:49 +0000127 return I;
Mike Stump1eb44332009-09-09 15:08:12 +0000128
Ted Kremenek4adc81e2008-08-13 04:27:00 +0000129 GRState* I = (GRState*) Alloc.Allocate<GRState>();
Mike Stump1eb44332009-09-09 15:08:12 +0000130 new (I) GRState(State);
Ted Kremenek9153f732008-02-05 07:17:49 +0000131 StateSet.InsertNode(I, InsertPos);
132 return I;
133}
Ted Kremeneke7d22112008-02-11 19:21:59 +0000134
Ted Kremenek67f28532009-06-17 22:02:04 +0000135const GRState* GRState::makeWithStore(Store store) const {
136 GRState NewSt = *this;
Zhongxing Xu4193eca2008-12-20 06:32:12 +0000137 NewSt.St = store;
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000138 return getStateManager().getPersistentState(NewSt);
Zhongxing Xu4193eca2008-12-20 06:32:12 +0000139}
140
Ted Kremenek1c72ef02008-08-16 00:49:49 +0000141//===----------------------------------------------------------------------===//
142// State pretty-printing.
143//===----------------------------------------------------------------------===//
Ted Kremenek461f9772008-03-11 18:57:24 +0000144
Zhongxing Xuc179a7f2010-03-05 04:45:36 +0000145void GRState::print(llvm::raw_ostream& Out, CFG &C, const char* nl,
Mike Stump1eb44332009-09-09 15:08:12 +0000146 const char* sep) const {
Ted Kremeneka622d8c2008-08-19 22:24:03 +0000147 // Print the store.
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000148 GRStateManager &Mgr = getStateManager();
149 Mgr.getStoreManager().print(getStore(), Out, nl, sep);
Mike Stump1eb44332009-09-09 15:08:12 +0000150
Ted Kremeneke7d22112008-02-11 19:21:59 +0000151 // Print Subexpression bindings.
Ted Kremeneka622d8c2008-08-19 22:24:03 +0000152 bool isFirst = true;
Mike Stump1eb44332009-09-09 15:08:12 +0000153
154 for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000155 if (C.isBlkExpr(I.getKey()))
156 continue;
Mike Stump1eb44332009-09-09 15:08:12 +0000157
Ted Kremeneke7d22112008-02-11 19:21:59 +0000158 if (isFirst) {
Ted Kremenek59894f92008-03-04 18:30:35 +0000159 Out << nl << nl << "Sub-Expressions:" << nl;
Ted Kremeneke7d22112008-02-11 19:21:59 +0000160 isFirst = false;
161 }
Ted Kremenek59894f92008-03-04 18:30:35 +0000162 else { Out << nl; }
Mike Stump1eb44332009-09-09 15:08:12 +0000163
Ted Kremeneke7d22112008-02-11 19:21:59 +0000164 Out << " (" << (void*) I.getKey() << ") ";
Chris Lattnere4f21422009-06-30 01:26:17 +0000165 LangOptions LO; // FIXME.
166 I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
Ted Kremenek6f9b3a42009-07-13 23:53:06 +0000167 Out << " : " << I.getData();
Ted Kremeneke7d22112008-02-11 19:21:59 +0000168 }
Mike Stump1eb44332009-09-09 15:08:12 +0000169
Ted Kremeneke7d22112008-02-11 19:21:59 +0000170 // Print block-expression bindings.
Ted Kremeneke7d22112008-02-11 19:21:59 +0000171 isFirst = true;
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000172
173 for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
174 if (!C.isBlkExpr(I.getKey()))
175 continue;
Ted Kremeneke7d22112008-02-11 19:21:59 +0000176
177 if (isFirst) {
Ted Kremenek59894f92008-03-04 18:30:35 +0000178 Out << nl << nl << "Block-level Expressions:" << nl;
Ted Kremeneke7d22112008-02-11 19:21:59 +0000179 isFirst = false;
180 }
Ted Kremenek59894f92008-03-04 18:30:35 +0000181 else { Out << nl; }
Mike Stump1eb44332009-09-09 15:08:12 +0000182
Ted Kremeneke7d22112008-02-11 19:21:59 +0000183 Out << " (" << (void*) I.getKey() << ") ";
Chris Lattnere4f21422009-06-30 01:26:17 +0000184 LangOptions LO; // FIXME.
185 I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
Ted Kremenek6f9b3a42009-07-13 23:53:06 +0000186 Out << " : " << I.getData();
Ted Kremeneke7d22112008-02-11 19:21:59 +0000187 }
Mike Stump1eb44332009-09-09 15:08:12 +0000188
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000189 Mgr.getConstraintManager().print(this, Out, nl, sep);
Mike Stump1eb44332009-09-09 15:08:12 +0000190
Ted Kremenekb65be702009-06-18 01:23:53 +0000191 // Print checker-specific data.
Ted Kremenek0fb0bc42009-08-27 01:39:13 +0000192 for (std::vector<Printer*>::iterator I = Mgr.Printers.begin(),
193 E = Mgr.Printers.end(); I != E; ++I) {
Ted Kremenekb65be702009-06-18 01:23:53 +0000194 (*I)->Print(Out, this, nl, sep);
195 }
Ted Kremeneke7d22112008-02-11 19:21:59 +0000196}
Ted Kremenek729a9a22008-07-17 23:15:45 +0000197
Zhongxing Xuc179a7f2010-03-05 04:45:36 +0000198void GRState::printDOT(llvm::raw_ostream& Out, CFG &C) const {
199 print(Out, C, "\\l", "\\|");
Ted Kremenek1c72ef02008-08-16 00:49:49 +0000200}
201
Zhongxing Xuc179a7f2010-03-05 04:45:36 +0000202void GRState::printStdErr(CFG &C) const {
203 print(llvm::errs(), C);
Ted Kremenek1c72ef02008-08-16 00:49:49 +0000204}
205
Ted Kremenek72cd17f2008-08-14 21:16:54 +0000206//===----------------------------------------------------------------------===//
207// Generic Data Map.
208//===----------------------------------------------------------------------===//
209
210void* const* GRState::FindGDM(void* K) const {
211 return GDM.lookup(K);
212}
213
Ted Kremenek1c72ef02008-08-16 00:49:49 +0000214void*
215GRStateManager::FindGDMContext(void* K,
216 void* (*CreateContext)(llvm::BumpPtrAllocator&),
217 void (*DeleteContext)(void*)) {
Mike Stump1eb44332009-09-09 15:08:12 +0000218
Ted Kremenek1c72ef02008-08-16 00:49:49 +0000219 std::pair<void*, void (*)(void*)>& p = GDMContexts[K];
220 if (!p.first) {
221 p.first = CreateContext(Alloc);
222 p.second = DeleteContext;
223 }
Mike Stump1eb44332009-09-09 15:08:12 +0000224
Ted Kremenek1c72ef02008-08-16 00:49:49 +0000225 return p.first;
226}
227
Zhongxing Xu4230da62008-11-03 05:18:34 +0000228const GRState* GRStateManager::addGDM(const GRState* St, void* Key, void* Data){
Ted Kremenek72cd17f2008-08-14 21:16:54 +0000229 GRState::GenericDataMap M1 = St->getGDM();
230 GRState::GenericDataMap M2 = GDMFactory.Add(M1, Key, Data);
Mike Stump1eb44332009-09-09 15:08:12 +0000231
Ted Kremenek72cd17f2008-08-14 21:16:54 +0000232 if (M1 == M2)
233 return St;
Mike Stump1eb44332009-09-09 15:08:12 +0000234
Ted Kremenek72cd17f2008-08-14 21:16:54 +0000235 GRState NewSt = *St;
236 NewSt.GDM = M2;
237 return getPersistentState(NewSt);
238}
Ted Kremenek584def72008-07-22 00:46:16 +0000239
Zhongxing Xu0541d102010-03-25 01:39:39 +0000240const GRState *GRStateManager::removeGDM(const GRState *state, void *Key) {
241 GRState::GenericDataMap OldM = state->getGDM();
242 GRState::GenericDataMap NewM = GDMFactory.Remove(OldM, Key);
243
244 if (NewM == OldM)
245 return state;
246
247 GRState NewState = *state;
248 NewState.GDM = NewM;
249 return getPersistentState(NewState);
250}
251
Ted Kremenek584def72008-07-22 00:46:16 +0000252//===----------------------------------------------------------------------===//
Ted Kremenek5216ad72009-02-14 03:16:10 +0000253// Utility.
254//===----------------------------------------------------------------------===//
255
Ted Kremenek5dc27462009-03-03 02:51:43 +0000256namespace {
Kovarththanan Rajaratnamba5fb5a2009-11-28 06:07:30 +0000257class ScanReachableSymbols : public SubRegionMap::Visitor {
Ted Kremenek5dc27462009-03-03 02:51:43 +0000258 typedef llvm::DenseSet<const MemRegion*> VisitedRegionsTy;
259
260 VisitedRegionsTy visited;
Ted Kremenek47fed902009-06-18 01:33:24 +0000261 const GRState *state;
Ted Kremenek5dc27462009-03-03 02:51:43 +0000262 SymbolVisitor &visitor;
263 llvm::OwningPtr<SubRegionMap> SRM;
264public:
Mike Stump1eb44332009-09-09 15:08:12 +0000265
Ted Kremenek47fed902009-06-18 01:33:24 +0000266 ScanReachableSymbols(const GRState *st, SymbolVisitor& v)
267 : state(st), visitor(v) {}
Mike Stump1eb44332009-09-09 15:08:12 +0000268
Ted Kremenek5dc27462009-03-03 02:51:43 +0000269 bool scan(nonloc::CompoundVal val);
270 bool scan(SVal val);
271 bool scan(const MemRegion *R);
Mike Stump1eb44332009-09-09 15:08:12 +0000272
Ted Kremenek5dc27462009-03-03 02:51:43 +0000273 // From SubRegionMap::Visitor.
274 bool Visit(const MemRegion* Parent, const MemRegion* SubRegion) {
275 return scan(SubRegion);
276 }
277};
278}
279
280bool ScanReachableSymbols::scan(nonloc::CompoundVal val) {
Ted Kremenek5216ad72009-02-14 03:16:10 +0000281 for (nonloc::CompoundVal::iterator I=val.begin(), E=val.end(); I!=E; ++I)
Ted Kremenek5dc27462009-03-03 02:51:43 +0000282 if (!scan(*I))
283 return false;
Ted Kremenek5216ad72009-02-14 03:16:10 +0000284
285 return true;
286}
Mike Stump1eb44332009-09-09 15:08:12 +0000287
Ted Kremenek5dc27462009-03-03 02:51:43 +0000288bool ScanReachableSymbols::scan(SVal val) {
289 if (loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(&val))
290 return scan(X->getRegion());
Ted Kremenek380022d2009-03-30 18:45:36 +0000291
Zhongxing Xu951b3342010-01-11 07:40:00 +0000292 if (nonloc::LocAsInteger *X = dyn_cast<nonloc::LocAsInteger>(&val))
293 return scan(X->getLoc());
294
Ted Kremenek380022d2009-03-30 18:45:36 +0000295 if (SymbolRef Sym = val.getAsSymbol())
296 return visitor.VisitSymbol(Sym);
Mike Stump1eb44332009-09-09 15:08:12 +0000297
Ted Kremenek5216ad72009-02-14 03:16:10 +0000298 if (nonloc::CompoundVal *X = dyn_cast<nonloc::CompoundVal>(&val))
Ted Kremenek5dc27462009-03-03 02:51:43 +0000299 return scan(*X);
Mike Stump1eb44332009-09-09 15:08:12 +0000300
Ted Kremenek5216ad72009-02-14 03:16:10 +0000301 return true;
302}
Mike Stump1eb44332009-09-09 15:08:12 +0000303
Ted Kremenek5dc27462009-03-03 02:51:43 +0000304bool ScanReachableSymbols::scan(const MemRegion *R) {
Ted Kremenek1cb151e2009-03-04 00:13:10 +0000305 if (isa<MemSpaceRegion>(R) || visited.count(R))
Ted Kremenek5dc27462009-03-03 02:51:43 +0000306 return true;
Mike Stump1eb44332009-09-09 15:08:12 +0000307
Ted Kremenek5dc27462009-03-03 02:51:43 +0000308 visited.insert(R);
309
310 // If this is a symbolic region, visit the symbol for the region.
311 if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R))
312 if (!visitor.VisitSymbol(SR->getSymbol()))
313 return false;
Mike Stump1eb44332009-09-09 15:08:12 +0000314
Ted Kremenek5dc27462009-03-03 02:51:43 +0000315 // If this is a subregion, also visit the parent regions.
316 if (const SubRegion *SR = dyn_cast<SubRegion>(R))
Ted Kremenek6076e0a2009-03-03 18:15:30 +0000317 if (!scan(SR->getSuperRegion()))
Ted Kremenek5dc27462009-03-03 02:51:43 +0000318 return false;
Mike Stump1eb44332009-09-09 15:08:12 +0000319
Ted Kremenek5dc27462009-03-03 02:51:43 +0000320 // Now look at the binding to this region (if any).
Ted Kremenek13976632010-02-08 16:18:51 +0000321 if (!scan(state->getSValAsScalarOrLoc(R)))
Ted Kremenek5dc27462009-03-03 02:51:43 +0000322 return false;
Mike Stump1eb44332009-09-09 15:08:12 +0000323
Ted Kremenek5dc27462009-03-03 02:51:43 +0000324 // Now look at the subregions.
325 if (!SRM.get())
Zhongxing Xuf5416bd2010-02-05 05:18:47 +0000326 SRM.reset(state->getStateManager().getStoreManager().
327 getSubRegionMap(state->getStore()));
Mike Stump1eb44332009-09-09 15:08:12 +0000328
Ted Kremenek5dc27462009-03-03 02:51:43 +0000329 return SRM->iterSubRegions(R, *this);
330}
331
Ted Kremenek47fed902009-06-18 01:33:24 +0000332bool GRState::scanReachableSymbols(SVal val, SymbolVisitor& visitor) const {
333 ScanReachableSymbols S(this, visitor);
Ted Kremenek5dc27462009-03-03 02:51:43 +0000334 return S.scan(val);
335}
Ted Kremenek5216ad72009-02-14 03:16:10 +0000336
Ted Kremenek9dce71f2009-11-26 02:32:19 +0000337bool GRState::scanReachableSymbols(const SVal *I, const SVal *E,
338 SymbolVisitor &visitor) const {
339 ScanReachableSymbols S(this, visitor);
340 for ( ; I != E; ++I) {
Ted Kremenek43f19f72009-12-01 17:50:25 +0000341 if (!S.scan(*I))
342 return false;
Ted Kremenek9dce71f2009-11-26 02:32:19 +0000343 }
Ted Kremenek43f19f72009-12-01 17:50:25 +0000344 return true;
Ted Kremenek9dce71f2009-11-26 02:32:19 +0000345}
346
347bool GRState::scanReachableSymbols(const MemRegion * const *I,
348 const MemRegion * const *E,
349 SymbolVisitor &visitor) const {
350 ScanReachableSymbols S(this, visitor);
351 for ( ; I != E; ++I) {
Ted Kremenek43f19f72009-12-01 17:50:25 +0000352 if (!S.scan(*I))
353 return false;
Ted Kremenek9dce71f2009-11-26 02:32:19 +0000354 }
Ted Kremenek43f19f72009-12-01 17:50:25 +0000355 return true;
Ted Kremenek9dce71f2009-11-26 02:32:19 +0000356}