blob: 6c3f7b2245df04b2b0573445add7ff74617d31bc [file] [log] [blame]
Zhongxing Xud19e21b2008-08-29 15:09:12 +00001//== BasicConstraintManager.cpp - Manage basic constraints.------*- 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//
Mike Stump1eb44332009-09-09 15:08:12 +000010// This file defines BasicConstraintManager, a class that tracks simple
Zhongxing Xud19e21b2008-08-29 15:09:12 +000011// equality and inequality constraints on symbolic values of GRState.
12//
13//===----------------------------------------------------------------------===//
14
Ted Kremenek45021952009-02-14 17:08:39 +000015#include "SimpleConstraintManager.h"
Zhongxing Xu30ad1672008-08-27 14:03:33 +000016#include "clang/Analysis/PathSensitive/GRState.h"
Zhongxing Xu39cfed32008-08-29 14:52:36 +000017#include "clang/Analysis/PathSensitive/GRStateTrait.h"
Ted Kremenek2fb78a72008-12-17 21:50:35 +000018#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
Zhongxing Xu39cfed32008-08-29 14:52:36 +000019#include "llvm/Support/raw_ostream.h"
Zhongxing Xu30ad1672008-08-27 14:03:33 +000020
21using namespace clang;
22
Ted Kremenek8ee74d52009-01-26 06:04:53 +000023
Kovarththanan Rajaratnamba5fb5a2009-11-28 06:07:30 +000024namespace { class ConstNotEq {}; }
25namespace { class ConstEq {}; }
Zhongxing Xu30ad1672008-08-27 14:03:33 +000026
Ted Kremenek2dabd432008-12-05 02:27:51 +000027typedef llvm::ImmutableMap<SymbolRef,GRState::IntSetTy> ConstNotEqTy;
28typedef llvm::ImmutableMap<SymbolRef,const llvm::APSInt*> ConstEqTy;
Mike Stump1eb44332009-09-09 15:08:12 +000029
Ted Kremenek8ee74d52009-01-26 06:04:53 +000030static int ConstEqIndex = 0;
31static int ConstNotEqIndex = 0;
Zhongxing Xu39cfed32008-08-29 14:52:36 +000032
Ted Kremenek8ee74d52009-01-26 06:04:53 +000033namespace clang {
34template<>
35struct GRStateTrait<ConstNotEq> : public GRStatePartialTrait<ConstNotEqTy> {
Mike Stump1eb44332009-09-09 15:08:12 +000036 static inline void* GDMIndex() { return &ConstNotEqIndex; }
Ted Kremenek8ee74d52009-01-26 06:04:53 +000037};
38
39template<>
40struct GRStateTrait<ConstEq> : public GRStatePartialTrait<ConstEqTy> {
Mike Stump1eb44332009-09-09 15:08:12 +000041 static inline void* GDMIndex() { return &ConstEqIndex; }
Ted Kremenek8ee74d52009-01-26 06:04:53 +000042};
Mike Stump1eb44332009-09-09 15:08:12 +000043}
44
Ted Kremenek8ee74d52009-01-26 06:04:53 +000045namespace {
Zhongxing Xu30ad1672008-08-27 14:03:33 +000046// BasicConstraintManager only tracks equality and inequality constraints of
47// constants and integer variables.
Kovarththanan Rajaratnamba5fb5a2009-11-28 06:07:30 +000048class BasicConstraintManager
Ted Kremenek45021952009-02-14 17:08:39 +000049 : public SimpleConstraintManager {
Zhongxing Xuf0bc50e2008-11-27 06:08:40 +000050 GRState::IntSetTy::Factory ISetFactory;
Zhongxing Xu30ad1672008-08-27 14:03:33 +000051public:
Mike Stump1eb44332009-09-09 15:08:12 +000052 BasicConstraintManager(GRStateManager& statemgr)
Ted Kremenekf1b82272009-06-18 23:20:05 +000053 : ISetFactory(statemgr.getAllocator()) {}
Zhongxing Xu30ad1672008-08-27 14:03:33 +000054
Ted Kremeneka591bc02009-06-18 22:57:13 +000055 const GRState* AssumeSymNE(const GRState* state, SymbolRef sym,
56 const llvm::APSInt& V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +000057
Ted Kremeneka591bc02009-06-18 22:57:13 +000058 const GRState* AssumeSymEQ(const GRState* state, SymbolRef sym,
59 const llvm::APSInt& V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +000060
Ted Kremeneka591bc02009-06-18 22:57:13 +000061 const GRState* AssumeSymLT(const GRState* state, SymbolRef sym,
62 const llvm::APSInt& V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +000063
Ted Kremeneka591bc02009-06-18 22:57:13 +000064 const GRState* AssumeSymGT(const GRState* state, SymbolRef sym,
65 const llvm::APSInt& V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +000066
Ted Kremeneka591bc02009-06-18 22:57:13 +000067 const GRState* AssumeSymGE(const GRState* state, SymbolRef sym,
68 const llvm::APSInt& V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +000069
Ted Kremeneka591bc02009-06-18 22:57:13 +000070 const GRState* AssumeSymLE(const GRState* state, SymbolRef sym,
71 const llvm::APSInt& V);
Zhongxing Xu39cfed32008-08-29 14:52:36 +000072
Ted Kremeneka591bc02009-06-18 22:57:13 +000073 const GRState* AddEQ(const GRState* state, SymbolRef sym, const llvm::APSInt& V);
Zhongxing Xu39cfed32008-08-29 14:52:36 +000074
Ted Kremeneka591bc02009-06-18 22:57:13 +000075 const GRState* AddNE(const GRState* state, SymbolRef sym, const llvm::APSInt& V);
Zhongxing Xu39cfed32008-08-29 14:52:36 +000076
Ted Kremeneka591bc02009-06-18 22:57:13 +000077 const llvm::APSInt* getSymVal(const GRState* state, SymbolRef sym) const;
78 bool isNotEqual(const GRState* state, SymbolRef sym, const llvm::APSInt& V)
Ted Kremenek45021952009-02-14 17:08:39 +000079 const;
Ted Kremeneka591bc02009-06-18 22:57:13 +000080 bool isEqual(const GRState* state, SymbolRef sym, const llvm::APSInt& V)
Ted Kremenek45021952009-02-14 17:08:39 +000081 const;
Zhongxing Xu39cfed32008-08-29 14:52:36 +000082
Ted Kremeneka591bc02009-06-18 22:57:13 +000083 const GRState* RemoveDeadBindings(const GRState* state, SymbolReaper& SymReaper);
Ted Kremenek241677a2009-01-21 22:26:05 +000084
Mike Stump1eb44332009-09-09 15:08:12 +000085 void print(const GRState* state, llvm::raw_ostream& Out,
Zhongxing Xu39cfed32008-08-29 14:52:36 +000086 const char* nl, const char *sep);
87};
Zhongxing Xu30ad1672008-08-27 14:03:33 +000088
89} // end anonymous namespace
90
91ConstraintManager* clang::CreateBasicConstraintManager(GRStateManager& StateMgr)
92{
93 return new BasicConstraintManager(StateMgr);
94}
95
Zhongxing Xu30ad1672008-08-27 14:03:33 +000096const GRState*
Ted Kremeneka591bc02009-06-18 22:57:13 +000097BasicConstraintManager::AssumeSymNE(const GRState *state, SymbolRef sym,
98 const llvm::APSInt& V) {
Zhongxing Xu30ad1672008-08-27 14:03:33 +000099 // First, determine if sym == X, where X != V.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000100 if (const llvm::APSInt* X = getSymVal(state, sym)) {
101 bool isFeasible = (*X != V);
102 return isFeasible ? state : NULL;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000103 }
104
105 // Second, determine if sym != V.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000106 if (isNotEqual(state, sym, V))
107 return state;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000108
109 // If we reach here, sym is not a constant and we don't know if it is != V.
110 // Make that assumption.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000111 return AddNE(state, sym, V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000112}
113
Ted Kremeneka591bc02009-06-18 22:57:13 +0000114const GRState *BasicConstraintManager::AssumeSymEQ(const GRState *state,
115 SymbolRef sym,
116 const llvm::APSInt &V) {
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000117 // First, determine if sym == X, where X != V.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000118 if (const llvm::APSInt* X = getSymVal(state, sym)) {
119 bool isFeasible = *X == V;
120 return isFeasible ? state : NULL;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000121 }
122
123 // Second, determine if sym != V.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000124 if (isNotEqual(state, sym, V))
125 return NULL;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000126
127 // If we reach here, sym is not a constant and we don't know if it is == V.
128 // Make that assumption.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000129 return AddEQ(state, sym, V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000130}
131
132// These logic will be handled in another ConstraintManager.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000133const GRState *BasicConstraintManager::AssumeSymLT(const GRState *state,
134 SymbolRef sym,
Mike Stump1eb44332009-09-09 15:08:12 +0000135 const llvm::APSInt& V) {
Ted Kremenek73abd132008-12-03 18:56:12 +0000136 // Is 'V' the smallest possible value?
Chris Lattner071e04e2009-01-30 01:58:33 +0000137 if (V == llvm::APSInt::getMinValue(V.getBitWidth(), V.isUnsigned())) {
Ted Kremenek73abd132008-12-03 18:56:12 +0000138 // sym cannot be any value less than 'V'. This path is infeasible.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000139 return NULL;
Ted Kremenek73abd132008-12-03 18:56:12 +0000140 }
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000141
142 // FIXME: For now have assuming x < y be the same as assuming sym != V;
Ted Kremeneka591bc02009-06-18 22:57:13 +0000143 return AssumeSymNE(state, sym, V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000144}
145
Ted Kremeneka591bc02009-06-18 22:57:13 +0000146const GRState *BasicConstraintManager::AssumeSymGT(const GRState *state,
147 SymbolRef sym,
148 const llvm::APSInt& V) {
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000149
Ted Kremenekd7ff4872008-12-03 19:06:30 +0000150 // Is 'V' the largest possible value?
Chris Lattner071e04e2009-01-30 01:58:33 +0000151 if (V == llvm::APSInt::getMaxValue(V.getBitWidth(), V.isUnsigned())) {
Ted Kremenekd7ff4872008-12-03 19:06:30 +0000152 // sym cannot be any value greater than 'V'. This path is infeasible.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000153 return NULL;
Ted Kremenekd7ff4872008-12-03 19:06:30 +0000154 }
155
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000156 // FIXME: For now have assuming x > y be the same as assuming sym != V;
Ted Kremeneka591bc02009-06-18 22:57:13 +0000157 return AssumeSymNE(state, sym, V);
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000158}
159
Ted Kremeneka591bc02009-06-18 22:57:13 +0000160const GRState *BasicConstraintManager::AssumeSymGE(const GRState *state,
161 SymbolRef sym,
162 const llvm::APSInt &V) {
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000163
Ted Kremenek8c3e7fb2008-09-16 23:24:45 +0000164 // Reject a path if the value of sym is a constant X and !(X >= V).
Ted Kremeneka591bc02009-06-18 22:57:13 +0000165 if (const llvm::APSInt *X = getSymVal(state, sym)) {
166 bool isFeasible = *X >= V;
167 return isFeasible ? state : NULL;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000168 }
Mike Stump1eb44332009-09-09 15:08:12 +0000169
Ted Kremenekd7ff4872008-12-03 19:06:30 +0000170 // Sym is not a constant, but it is worth looking to see if V is the
171 // maximum integer value.
Chris Lattner071e04e2009-01-30 01:58:33 +0000172 if (V == llvm::APSInt::getMaxValue(V.getBitWidth(), V.isUnsigned())) {
Ted Kremenekd7ff4872008-12-03 19:06:30 +0000173 // If we know that sym != V, then this condition is infeasible since
Mike Stump1eb44332009-09-09 15:08:12 +0000174 // there is no other value greater than V.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000175 bool isFeasible = !isNotEqual(state, sym, V);
Mike Stump1eb44332009-09-09 15:08:12 +0000176
Ted Kremenekd7ff4872008-12-03 19:06:30 +0000177 // If the path is still feasible then as a consequence we know that
178 // 'sym == V' because we cannot have 'sym > V' (no larger values).
179 // Add this constraint.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000180 return isFeasible ? AddEQ(state, sym, V) : NULL;
Ted Kremenekd7ff4872008-12-03 19:06:30 +0000181 }
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000182
Ted Kremeneka591bc02009-06-18 22:57:13 +0000183 return state;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000184}
185
186const GRState*
Ted Kremeneka591bc02009-06-18 22:57:13 +0000187BasicConstraintManager::AssumeSymLE(const GRState* state, SymbolRef sym,
188 const llvm::APSInt& V) {
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000189
Ted Kremenek73abd132008-12-03 18:56:12 +0000190 // Reject a path if the value of sym is a constant X and !(X <= V).
Ted Kremeneka591bc02009-06-18 22:57:13 +0000191 if (const llvm::APSInt* X = getSymVal(state, sym)) {
192 bool isFeasible = *X <= V;
193 return isFeasible ? state : NULL;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000194 }
Mike Stump1eb44332009-09-09 15:08:12 +0000195
Ted Kremenek73abd132008-12-03 18:56:12 +0000196 // Sym is not a constant, but it is worth looking to see if V is the
197 // minimum integer value.
Chris Lattner071e04e2009-01-30 01:58:33 +0000198 if (V == llvm::APSInt::getMinValue(V.getBitWidth(), V.isUnsigned())) {
Ted Kremenek73abd132008-12-03 18:56:12 +0000199 // If we know that sym != V, then this condition is infeasible since
Mike Stump1eb44332009-09-09 15:08:12 +0000200 // there is no other value less than V.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000201 bool isFeasible = !isNotEqual(state, sym, V);
Mike Stump1eb44332009-09-09 15:08:12 +0000202
Ted Kremenek73abd132008-12-03 18:56:12 +0000203 // If the path is still feasible then as a consequence we know that
204 // 'sym == V' because we cannot have 'sym < V' (no smaller values).
205 // Add this constraint.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000206 return isFeasible ? AddEQ(state, sym, V) : NULL;
Ted Kremenek73abd132008-12-03 18:56:12 +0000207 }
Mike Stump1eb44332009-09-09 15:08:12 +0000208
Ted Kremeneka591bc02009-06-18 22:57:13 +0000209 return state;
Zhongxing Xu30ad1672008-08-27 14:03:33 +0000210}
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000211
Ted Kremenekc8781382009-06-17 22:28:13 +0000212const GRState* BasicConstraintManager::AddEQ(const GRState* state, SymbolRef sym,
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000213 const llvm::APSInt& V) {
214 // Create a new state with the old binding replaced.
Ted Kremenekc8781382009-06-17 22:28:13 +0000215 return state->set<ConstEq>(sym, &V);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000216}
217
Ted Kremenekc8781382009-06-17 22:28:13 +0000218const GRState* BasicConstraintManager::AddNE(const GRState* state, SymbolRef sym,
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000219 const llvm::APSInt& V) {
Zhongxing Xuf0bc50e2008-11-27 06:08:40 +0000220
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000221 // First, retrieve the NE-set associated with the given symbol.
Ted Kremenekc8781382009-06-17 22:28:13 +0000222 ConstNotEqTy::data_type* T = state->get<ConstNotEq>(sym);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000223 GRState::IntSetTy S = T ? *T : ISetFactory.GetEmptySet();
Mike Stump1eb44332009-09-09 15:08:12 +0000224
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000225 // Now add V to the NE set.
226 S = ISetFactory.Add(S, &V);
Mike Stump1eb44332009-09-09 15:08:12 +0000227
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000228 // Create a new state with the old binding replaced.
Ted Kremenekc8781382009-06-17 22:28:13 +0000229 return state->set<ConstNotEq>(sym, S);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000230}
231
Ted Kremeneka591bc02009-06-18 22:57:13 +0000232const llvm::APSInt* BasicConstraintManager::getSymVal(const GRState* state,
Ted Kremenek45021952009-02-14 17:08:39 +0000233 SymbolRef sym) const {
Ted Kremeneka591bc02009-06-18 22:57:13 +0000234 const ConstEqTy::data_type* T = state->get<ConstEq>(sym);
Ted Kremenek45021952009-02-14 17:08:39 +0000235 return T ? *T : NULL;
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000236}
237
Mike Stump1eb44332009-09-09 15:08:12 +0000238bool BasicConstraintManager::isNotEqual(const GRState* state, SymbolRef sym,
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000239 const llvm::APSInt& V) const {
240
241 // Retrieve the NE-set associated with the given symbol.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000242 const ConstNotEqTy::data_type* T = state->get<ConstNotEq>(sym);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000243
244 // See if V is present in the NE-set.
245 return T ? T->contains(&V) : false;
246}
247
Ted Kremeneka591bc02009-06-18 22:57:13 +0000248bool BasicConstraintManager::isEqual(const GRState* state, SymbolRef sym,
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000249 const llvm::APSInt& V) const {
250 // Retrieve the EQ-set associated with the given symbol.
Ted Kremeneka591bc02009-06-18 22:57:13 +0000251 const ConstEqTy::data_type* T = state->get<ConstEq>(sym);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000252 // See if V is present in the EQ-set.
253 return T ? **T == V : false;
254}
255
Zhongxing Xu8fd9b352008-11-27 02:39:34 +0000256/// Scan all symbols referenced by the constraints. If the symbol is not alive
257/// as marked in LSymbols, mark it as dead in DSymbols.
Ted Kremenek241677a2009-01-21 22:26:05 +0000258const GRState*
Ted Kremenekc8781382009-06-17 22:28:13 +0000259BasicConstraintManager::RemoveDeadBindings(const GRState* state,
Ted Kremenek241677a2009-01-21 22:26:05 +0000260 SymbolReaper& SymReaper) {
261
Ted Kremenekc8781382009-06-17 22:28:13 +0000262 ConstEqTy CE = state->get<ConstEq>();
263 ConstEqTy::Factory& CEFactory = state->get_context<ConstEq>();
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000264
265 for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I) {
Ted Kremenek241677a2009-01-21 22:26:05 +0000266 SymbolRef sym = I.getKey();
267 if (SymReaper.maybeDead(sym)) CE = CEFactory.Remove(CE, sym);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000268 }
Ted Kremenekc8781382009-06-17 22:28:13 +0000269 state = state->set<ConstEq>(CE);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000270
Ted Kremenekc8781382009-06-17 22:28:13 +0000271 ConstNotEqTy CNE = state->get<ConstNotEq>();
272 ConstNotEqTy::Factory& CNEFactory = state->get_context<ConstNotEq>();
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000273
274 for (ConstNotEqTy::iterator I = CNE.begin(), E = CNE.end(); I != E; ++I) {
Mike Stump1eb44332009-09-09 15:08:12 +0000275 SymbolRef sym = I.getKey();
Ted Kremenek241677a2009-01-21 22:26:05 +0000276 if (SymReaper.maybeDead(sym)) CNE = CNEFactory.Remove(CNE, sym);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000277 }
Mike Stump1eb44332009-09-09 15:08:12 +0000278
Ted Kremenekc8781382009-06-17 22:28:13 +0000279 return state->set<ConstNotEq>(CNE);
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000280}
281
Mike Stump1eb44332009-09-09 15:08:12 +0000282void BasicConstraintManager::print(const GRState* state, llvm::raw_ostream& Out,
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000283 const char* nl, const char *sep) {
284 // Print equality constraints.
285
Ted Kremeneka591bc02009-06-18 22:57:13 +0000286 ConstEqTy CE = state->get<ConstEq>();
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000287
288 if (!CE.isEmpty()) {
289 Out << nl << sep << "'==' constraints:";
Ted Kremenek53ba0b62009-06-24 23:06:47 +0000290 for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I)
291 Out << nl << " $" << I.getKey() << " : " << *I.getData();
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000292 }
293
294 // Print != constraints.
Mike Stump1eb44332009-09-09 15:08:12 +0000295
Ted Kremeneka591bc02009-06-18 22:57:13 +0000296 ConstNotEqTy CNE = state->get<ConstNotEq>();
Mike Stump1eb44332009-09-09 15:08:12 +0000297
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000298 if (!CNE.isEmpty()) {
299 Out << nl << sep << "'!=' constraints:";
Mike Stump1eb44332009-09-09 15:08:12 +0000300
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000301 for (ConstNotEqTy::iterator I = CNE.begin(), EI = CNE.end(); I!=EI; ++I) {
302 Out << nl << " $" << I.getKey() << " : ";
303 bool isFirst = true;
Mike Stump1eb44332009-09-09 15:08:12 +0000304
305 GRState::IntSetTy::iterator J = I.getData().begin(),
306 EJ = I.getData().end();
307
308 for ( ; J != EJ; ++J) {
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000309 if (isFirst) isFirst = false;
310 else Out << ", ";
Mike Stump1eb44332009-09-09 15:08:12 +0000311
Zhongxing Xu7d94e262008-11-10 05:00:06 +0000312 Out << (*J)->getSExtValue(); // Hack: should print to raw_ostream.
Zhongxing Xu39cfed32008-08-29 14:52:36 +0000313 }
314 }
315 }
Daniel Dunbar0e194dd2008-08-30 02:06:22 +0000316}