1 //== RangeConstraintManager.cpp - Manage range constraints.------*- C++ -*--==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines RangeConstraintManager, a class that tracks simple
11 // equality and inequality constraints on symbolic values of ProgramState.
13 //===----------------------------------------------------------------------===//
15 #include "SimpleConstraintManager.h"
16 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
17 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
18 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
19 #include "llvm/ADT/FoldingSet.h"
20 #include "llvm/ADT/ImmutableSet.h"
21 #include "llvm/Support/raw_ostream.h"
23 using namespace clang;
26 /// A Range represents the closed range [from, to]. The caller must
27 /// guarantee that from <= to. Note that Range is immutable, so as not
28 /// to subvert RangeSet's immutability.
30 class Range : public std::pair<const llvm::APSInt *, const llvm::APSInt *> {
32 Range(const llvm::APSInt &from, const llvm::APSInt &to)
33 : std::pair<const llvm::APSInt *, const llvm::APSInt *>(&from, &to) {
36 bool Includes(const llvm::APSInt &v) const {
37 return *first <= v && v <= *second;
39 const llvm::APSInt &From() const { return *first; }
40 const llvm::APSInt &To() const { return *second; }
41 const llvm::APSInt *getConcreteValue() const {
42 return &From() == &To() ? &From() : nullptr;
45 void Profile(llvm::FoldingSetNodeID &ID) const {
46 ID.AddPointer(&From());
51 class RangeTrait : public llvm::ImutContainerInfo<Range> {
53 // When comparing if one Range is less than another, we should compare
54 // the actual APSInt values instead of their pointers. This keeps the order
55 // consistent (instead of comparing by pointer values) and can potentially
56 // be used to speed up some of the operations in RangeSet.
57 static inline bool isLess(key_type_ref lhs, key_type_ref rhs) {
58 return *lhs.first < *rhs.first ||
59 (!(*rhs.first < *lhs.first) && *lhs.second < *rhs.second);
63 /// RangeSet contains a set of ranges. If the set is empty, then
64 /// there the value of a symbol is overly constrained and there are no
65 /// possible values for that symbol.
67 typedef llvm::ImmutableSet<Range, RangeTrait> PrimRangeSet;
68 PrimRangeSet ranges; // no need to make const, since it is an
69 // ImmutableSet - this allows default operator=
72 typedef PrimRangeSet::Factory Factory;
73 typedef PrimRangeSet::iterator iterator;
75 RangeSet(PrimRangeSet RS) : ranges(RS) {}
77 /// Create a new set with all ranges of this set and RS.
78 /// Possible intersections are not checked here.
79 RangeSet addRange(Factory &F, const RangeSet &RS) {
80 PrimRangeSet Ranges(RS.ranges);
81 for (const auto &range : ranges)
82 Ranges = F.add(Ranges, range);
83 return RangeSet(Ranges);
86 iterator begin() const { return ranges.begin(); }
87 iterator end() const { return ranges.end(); }
89 bool isEmpty() const { return ranges.isEmpty(); }
91 /// Construct a new RangeSet representing '{ [from, to] }'.
92 RangeSet(Factory &F, const llvm::APSInt &from, const llvm::APSInt &to)
93 : ranges(F.add(F.getEmptySet(), Range(from, to))) {}
95 /// Profile - Generates a hash profile of this RangeSet for use
97 void Profile(llvm::FoldingSetNodeID &ID) const { ranges.Profile(ID); }
99 /// getConcreteValue - If a symbol is contrained to equal a specific integer
100 /// constant then this method returns that value. Otherwise, it returns
102 const llvm::APSInt *getConcreteValue() const {
103 return ranges.isSingleton() ? ranges.begin()->getConcreteValue() : nullptr;
107 void IntersectInRange(BasicValueFactory &BV, Factory &F,
108 const llvm::APSInt &Lower, const llvm::APSInt &Upper,
109 PrimRangeSet &newRanges, PrimRangeSet::iterator &i,
110 PrimRangeSet::iterator &e) const {
111 // There are six cases for each range R in the set:
112 // 1. R is entirely before the intersection range.
113 // 2. R is entirely after the intersection range.
114 // 3. R contains the entire intersection range.
115 // 4. R starts before the intersection range and ends in the middle.
116 // 5. R starts in the middle of the intersection range and ends after it.
117 // 6. R is entirely contained in the intersection range.
118 // These correspond to each of the conditions below.
119 for (/* i = begin(), e = end() */; i != e; ++i) {
120 if (i->To() < Lower) {
123 if (i->From() > Upper) {
127 if (i->Includes(Lower)) {
128 if (i->Includes(Upper)) {
130 F.add(newRanges, Range(BV.getValue(Lower), BV.getValue(Upper)));
133 newRanges = F.add(newRanges, Range(BV.getValue(Lower), i->To()));
135 if (i->Includes(Upper)) {
136 newRanges = F.add(newRanges, Range(i->From(), BV.getValue(Upper)));
139 newRanges = F.add(newRanges, *i);
144 const llvm::APSInt &getMinValue() const {
146 return ranges.begin()->From();
149 bool pin(llvm::APSInt &Lower, llvm::APSInt &Upper) const {
150 // This function has nine cases, the cartesian product of range-testing
151 // both the upper and lower bounds against the symbol's type.
152 // Each case requires a different pinning operation.
153 // The function returns false if the described range is entirely outside
154 // the range of values for the associated symbol.
155 APSIntType Type(getMinValue());
156 APSIntType::RangeTestResultKind LowerTest = Type.testInRange(Lower, true);
157 APSIntType::RangeTestResultKind UpperTest = Type.testInRange(Upper, true);
160 case APSIntType::RTR_Below:
162 case APSIntType::RTR_Below:
163 // The entire range is outside the symbol's set of possible values.
164 // If this is a conventionally-ordered range, the state is infeasible.
168 // However, if the range wraps around, it spans all possible values.
169 Lower = Type.getMinValue();
170 Upper = Type.getMaxValue();
172 case APSIntType::RTR_Within:
173 // The range starts below what's possible but ends within it. Pin.
174 Lower = Type.getMinValue();
177 case APSIntType::RTR_Above:
178 // The range spans all possible values for the symbol. Pin.
179 Lower = Type.getMinValue();
180 Upper = Type.getMaxValue();
184 case APSIntType::RTR_Within:
186 case APSIntType::RTR_Below:
187 // The range wraps around, but all lower values are not possible.
189 Upper = Type.getMaxValue();
191 case APSIntType::RTR_Within:
192 // The range may or may not wrap around, but both limits are valid.
196 case APSIntType::RTR_Above:
197 // The range starts within what's possible but ends above it. Pin.
199 Upper = Type.getMaxValue();
203 case APSIntType::RTR_Above:
205 case APSIntType::RTR_Below:
206 // The range wraps but is outside the symbol's set of possible values.
208 case APSIntType::RTR_Within:
209 // The range starts above what's possible but ends within it (wrap).
210 Lower = Type.getMinValue();
213 case APSIntType::RTR_Above:
214 // The entire range is outside the symbol's set of possible values.
215 // If this is a conventionally-ordered range, the state is infeasible.
219 // However, if the range wraps around, it spans all possible values.
220 Lower = Type.getMinValue();
221 Upper = Type.getMaxValue();
231 // Returns a set containing the values in the receiving set, intersected with
232 // the closed range [Lower, Upper]. Unlike the Range type, this range uses
233 // modular arithmetic, corresponding to the common treatment of C integer
234 // overflow. Thus, if the Lower bound is greater than the Upper bound, the
235 // range is taken to wrap around. This is equivalent to taking the
236 // intersection with the two ranges [Min, Upper] and [Lower, Max],
237 // or, alternatively, /removing/ all integers between Upper and Lower.
238 RangeSet Intersect(BasicValueFactory &BV, Factory &F, llvm::APSInt Lower,
239 llvm::APSInt Upper) const {
240 if (!pin(Lower, Upper))
241 return F.getEmptySet();
243 PrimRangeSet newRanges = F.getEmptySet();
245 PrimRangeSet::iterator i = begin(), e = end();
247 IntersectInRange(BV, F, Lower, Upper, newRanges, i, e);
249 // The order of the next two statements is important!
250 // IntersectInRange() does not reset the iteration state for i and e.
251 // Therefore, the lower range most be handled first.
252 IntersectInRange(BV, F, BV.getMinValue(Upper), Upper, newRanges, i, e);
253 IntersectInRange(BV, F, Lower, BV.getMaxValue(Lower), newRanges, i, e);
259 void print(raw_ostream &os) const {
262 for (iterator i = begin(), e = end(); i != e; ++i) {
268 os << '[' << i->From().toString(10) << ", " << i->To().toString(10)
274 bool operator==(const RangeSet &other) const {
275 return ranges == other.ranges;
278 } // end anonymous namespace
280 REGISTER_TRAIT_WITH_PROGRAMSTATE(ConstraintRange,
281 CLANG_ENTO_PROGRAMSTATE_MAP(SymbolRef,
285 class RangeConstraintManager : public SimpleConstraintManager {
286 RangeSet getRange(ProgramStateRef State, SymbolRef Sym);
289 RangeConstraintManager(SubEngine *SE, SValBuilder &SVB)
290 : SimpleConstraintManager(SE, SVB) {}
292 ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym,
293 const llvm::APSInt &V,
294 const llvm::APSInt &Adjustment) override;
296 ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
297 const llvm::APSInt &V,
298 const llvm::APSInt &Adjustment) override;
300 ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
301 const llvm::APSInt &V,
302 const llvm::APSInt &Adjustment) override;
304 ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym,
305 const llvm::APSInt &V,
306 const llvm::APSInt &Adjustment) override;
308 ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym,
309 const llvm::APSInt &V,
310 const llvm::APSInt &Adjustment) override;
312 ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym,
313 const llvm::APSInt &V,
314 const llvm::APSInt &Adjustment) override;
316 ProgramStateRef assumeSymbolWithinInclusiveRange(
317 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
318 const llvm::APSInt &To, const llvm::APSInt &Adjustment) override;
320 ProgramStateRef assumeSymbolOutOfInclusiveRange(
321 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
322 const llvm::APSInt &To, const llvm::APSInt &Adjustment) override;
324 const llvm::APSInt *getSymVal(ProgramStateRef St,
325 SymbolRef Sym) const override;
326 ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym) override;
328 ProgramStateRef removeDeadBindings(ProgramStateRef St,
329 SymbolReaper &SymReaper) override;
331 void print(ProgramStateRef St, raw_ostream &Out, const char *nl,
332 const char *sep) override;
336 RangeSet getSymLTRange(ProgramStateRef St, SymbolRef Sym,
337 const llvm::APSInt &Int,
338 const llvm::APSInt &Adjustment);
339 RangeSet getSymGTRange(ProgramStateRef St, SymbolRef Sym,
340 const llvm::APSInt &Int,
341 const llvm::APSInt &Adjustment);
342 RangeSet getSymLERange(ProgramStateRef St, SymbolRef Sym,
343 const llvm::APSInt &Int,
344 const llvm::APSInt &Adjustment);
345 RangeSet getSymLERange(const RangeSet &RS, const llvm::APSInt &Int,
346 const llvm::APSInt &Adjustment);
347 RangeSet getSymGERange(ProgramStateRef St, SymbolRef Sym,
348 const llvm::APSInt &Int,
349 const llvm::APSInt &Adjustment);
352 } // end anonymous namespace
354 std::unique_ptr<ConstraintManager>
355 ento::CreateRangeConstraintManager(ProgramStateManager &StMgr, SubEngine *Eng) {
356 return llvm::make_unique<RangeConstraintManager>(Eng, StMgr.getSValBuilder());
359 const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St,
360 SymbolRef Sym) const {
361 const ConstraintRangeTy::data_type *T = St->get<ConstraintRange>(Sym);
362 return T ? T->getConcreteValue() : nullptr;
365 ConditionTruthVal RangeConstraintManager::checkNull(ProgramStateRef State,
367 const RangeSet *Ranges = State->get<ConstraintRange>(Sym);
369 // If we don't have any information about this symbol, it's underconstrained.
371 return ConditionTruthVal();
373 // If we have a concrete value, see if it's zero.
374 if (const llvm::APSInt *Value = Ranges->getConcreteValue())
377 BasicValueFactory &BV = getBasicVals();
378 APSIntType IntType = BV.getAPSIntType(Sym->getType());
379 llvm::APSInt Zero = IntType.getZeroValue();
381 // Check if zero is in the set of possible values.
382 if (Ranges->Intersect(BV, F, Zero, Zero).isEmpty())
385 // Zero is a possible value, but it is not the /only/ possible value.
386 return ConditionTruthVal();
389 /// Scan all symbols referenced by the constraints. If the symbol is not alive
390 /// as marked in LSymbols, mark it as dead in DSymbols.
392 RangeConstraintManager::removeDeadBindings(ProgramStateRef State,
393 SymbolReaper &SymReaper) {
394 bool Changed = false;
395 ConstraintRangeTy CR = State->get<ConstraintRange>();
396 ConstraintRangeTy::Factory &CRFactory = State->get_context<ConstraintRange>();
398 for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
399 SymbolRef Sym = I.getKey();
400 if (SymReaper.maybeDead(Sym)) {
402 CR = CRFactory.remove(CR, Sym);
406 return Changed ? State->set<ConstraintRange>(CR) : State;
409 RangeSet RangeConstraintManager::getRange(ProgramStateRef State,
411 if (ConstraintRangeTy::data_type *V = State->get<ConstraintRange>(Sym))
414 // Lazily generate a new RangeSet representing all possible values for the
415 // given symbol type.
416 BasicValueFactory &BV = getBasicVals();
417 QualType T = Sym->getType();
419 RangeSet Result(F, BV.getMinValue(T), BV.getMaxValue(T));
421 // Special case: references are known to be non-zero.
422 if (T->isReferenceType()) {
423 APSIntType IntType = BV.getAPSIntType(T);
424 Result = Result.Intersect(BV, F, ++IntType.getZeroValue(),
425 --IntType.getZeroValue());
431 //===------------------------------------------------------------------------===
432 // assumeSymX methods: public interface for RangeConstraintManager.
433 //===------------------------------------------------------------------------===/
435 // The syntax for ranges below is mathematical, using [x, y] for closed ranges
436 // and (x, y) for open ranges. These ranges are modular, corresponding with
437 // a common treatment of C integer overflow. This means that these methods
438 // do not have to worry about overflow; RangeSet::Intersect can handle such a
439 // "wraparound" range.
440 // As an example, the range [UINT_MAX-1, 3) contains five values: UINT_MAX-1,
441 // UINT_MAX, 0, 1, and 2.
444 RangeConstraintManager::assumeSymNE(ProgramStateRef St, SymbolRef Sym,
445 const llvm::APSInt &Int,
446 const llvm::APSInt &Adjustment) {
447 // Before we do any real work, see if the value can even show up.
448 APSIntType AdjustmentType(Adjustment);
449 if (AdjustmentType.testInRange(Int, true) != APSIntType::RTR_Within)
452 llvm::APSInt Lower = AdjustmentType.convert(Int) - Adjustment;
453 llvm::APSInt Upper = Lower;
457 // [Int-Adjustment+1, Int-Adjustment-1]
458 // Notice that the lower bound is greater than the upper bound.
459 RangeSet New = getRange(St, Sym).Intersect(getBasicVals(), F, Upper, Lower);
460 return New.isEmpty() ? nullptr : St->set<ConstraintRange>(Sym, New);
464 RangeConstraintManager::assumeSymEQ(ProgramStateRef St, SymbolRef Sym,
465 const llvm::APSInt &Int,
466 const llvm::APSInt &Adjustment) {
467 // Before we do any real work, see if the value can even show up.
468 APSIntType AdjustmentType(Adjustment);
469 if (AdjustmentType.testInRange(Int, true) != APSIntType::RTR_Within)
472 // [Int-Adjustment, Int-Adjustment]
473 llvm::APSInt AdjInt = AdjustmentType.convert(Int) - Adjustment;
474 RangeSet New = getRange(St, Sym).Intersect(getBasicVals(), F, AdjInt, AdjInt);
475 return New.isEmpty() ? nullptr : St->set<ConstraintRange>(Sym, New);
478 RangeSet RangeConstraintManager::getSymLTRange(ProgramStateRef St,
480 const llvm::APSInt &Int,
481 const llvm::APSInt &Adjustment) {
482 // Before we do any real work, see if the value can even show up.
483 APSIntType AdjustmentType(Adjustment);
484 switch (AdjustmentType.testInRange(Int, true)) {
485 case APSIntType::RTR_Below:
486 return F.getEmptySet();
487 case APSIntType::RTR_Within:
489 case APSIntType::RTR_Above:
490 return getRange(St, Sym);
493 // Special case for Int == Min. This is always false.
494 llvm::APSInt ComparisonVal = AdjustmentType.convert(Int);
495 llvm::APSInt Min = AdjustmentType.getMinValue();
496 if (ComparisonVal == Min)
497 return F.getEmptySet();
499 llvm::APSInt Lower = Min - Adjustment;
500 llvm::APSInt Upper = ComparisonVal - Adjustment;
503 return getRange(St, Sym).Intersect(getBasicVals(), F, Lower, Upper);
507 RangeConstraintManager::assumeSymLT(ProgramStateRef St, SymbolRef Sym,
508 const llvm::APSInt &Int,
509 const llvm::APSInt &Adjustment) {
510 RangeSet New = getSymLTRange(St, Sym, Int, Adjustment);
511 return New.isEmpty() ? nullptr : St->set<ConstraintRange>(Sym, New);
514 RangeSet RangeConstraintManager::getSymGTRange(ProgramStateRef St,
516 const llvm::APSInt &Int,
517 const llvm::APSInt &Adjustment) {
518 // Before we do any real work, see if the value can even show up.
519 APSIntType AdjustmentType(Adjustment);
520 switch (AdjustmentType.testInRange(Int, true)) {
521 case APSIntType::RTR_Below:
522 return getRange(St, Sym);
523 case APSIntType::RTR_Within:
525 case APSIntType::RTR_Above:
526 return F.getEmptySet();
529 // Special case for Int == Max. This is always false.
530 llvm::APSInt ComparisonVal = AdjustmentType.convert(Int);
531 llvm::APSInt Max = AdjustmentType.getMaxValue();
532 if (ComparisonVal == Max)
533 return F.getEmptySet();
535 llvm::APSInt Lower = ComparisonVal - Adjustment;
536 llvm::APSInt Upper = Max - Adjustment;
539 return getRange(St, Sym).Intersect(getBasicVals(), F, Lower, Upper);
543 RangeConstraintManager::assumeSymGT(ProgramStateRef St, SymbolRef Sym,
544 const llvm::APSInt &Int,
545 const llvm::APSInt &Adjustment) {
546 RangeSet New = getSymGTRange(St, Sym, Int, Adjustment);
547 return New.isEmpty() ? nullptr : St->set<ConstraintRange>(Sym, New);
550 RangeSet RangeConstraintManager::getSymGERange(ProgramStateRef St,
552 const llvm::APSInt &Int,
553 const llvm::APSInt &Adjustment) {
554 // Before we do any real work, see if the value can even show up.
555 APSIntType AdjustmentType(Adjustment);
556 switch (AdjustmentType.testInRange(Int, true)) {
557 case APSIntType::RTR_Below:
558 return getRange(St, Sym);
559 case APSIntType::RTR_Within:
561 case APSIntType::RTR_Above:
562 return F.getEmptySet();
565 // Special case for Int == Min. This is always feasible.
566 llvm::APSInt ComparisonVal = AdjustmentType.convert(Int);
567 llvm::APSInt Min = AdjustmentType.getMinValue();
568 if (ComparisonVal == Min)
569 return getRange(St, Sym);
571 llvm::APSInt Max = AdjustmentType.getMaxValue();
572 llvm::APSInt Lower = ComparisonVal - Adjustment;
573 llvm::APSInt Upper = Max - Adjustment;
575 return getRange(St, Sym).Intersect(getBasicVals(), F, Lower, Upper);
579 RangeConstraintManager::assumeSymGE(ProgramStateRef St, SymbolRef Sym,
580 const llvm::APSInt &Int,
581 const llvm::APSInt &Adjustment) {
582 RangeSet New = getSymGERange(St, Sym, Int, Adjustment);
583 return New.isEmpty() ? nullptr : St->set<ConstraintRange>(Sym, New);
586 RangeSet RangeConstraintManager::getSymLERange(const RangeSet &RS,
587 const llvm::APSInt &Int,
588 const llvm::APSInt &Adjustment) {
589 // Before we do any real work, see if the value can even show up.
590 APSIntType AdjustmentType(Adjustment);
591 switch (AdjustmentType.testInRange(Int, true)) {
592 case APSIntType::RTR_Below:
593 return F.getEmptySet();
594 case APSIntType::RTR_Within:
596 case APSIntType::RTR_Above:
600 // Special case for Int == Max. This is always feasible.
601 llvm::APSInt ComparisonVal = AdjustmentType.convert(Int);
602 llvm::APSInt Max = AdjustmentType.getMaxValue();
603 if (ComparisonVal == Max)
606 llvm::APSInt Min = AdjustmentType.getMinValue();
607 llvm::APSInt Lower = Min - Adjustment;
608 llvm::APSInt Upper = ComparisonVal - Adjustment;
610 return RS.Intersect(getBasicVals(), F, Lower, Upper);
613 RangeSet RangeConstraintManager::getSymLERange(ProgramStateRef St,
615 const llvm::APSInt &Int,
616 const llvm::APSInt &Adjustment) {
617 // Before we do any real work, see if the value can even show up.
618 APSIntType AdjustmentType(Adjustment);
619 switch (AdjustmentType.testInRange(Int, true)) {
620 case APSIntType::RTR_Below:
621 return F.getEmptySet();
622 case APSIntType::RTR_Within:
624 case APSIntType::RTR_Above:
625 return getRange(St, Sym);
628 // Special case for Int == Max. This is always feasible.
629 llvm::APSInt ComparisonVal = AdjustmentType.convert(Int);
630 llvm::APSInt Max = AdjustmentType.getMaxValue();
631 if (ComparisonVal == Max)
632 return getRange(St, Sym);
634 llvm::APSInt Min = AdjustmentType.getMinValue();
635 llvm::APSInt Lower = Min - Adjustment;
636 llvm::APSInt Upper = ComparisonVal - Adjustment;
638 return getRange(St, Sym).Intersect(getBasicVals(), F, Lower, Upper);
642 RangeConstraintManager::assumeSymLE(ProgramStateRef St, SymbolRef Sym,
643 const llvm::APSInt &Int,
644 const llvm::APSInt &Adjustment) {
645 RangeSet New = getSymLERange(St, Sym, Int, Adjustment);
646 return New.isEmpty() ? nullptr : St->set<ConstraintRange>(Sym, New);
649 ProgramStateRef RangeConstraintManager::assumeSymbolWithinInclusiveRange(
650 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
651 const llvm::APSInt &To, const llvm::APSInt &Adjustment) {
652 RangeSet New = getSymGERange(State, Sym, From, Adjustment);
655 New = getSymLERange(New, To, Adjustment);
656 return New.isEmpty() ? nullptr : State->set<ConstraintRange>(Sym, New);
659 ProgramStateRef RangeConstraintManager::assumeSymbolOutOfInclusiveRange(
660 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
661 const llvm::APSInt &To, const llvm::APSInt &Adjustment) {
662 RangeSet RangeLT = getSymLTRange(State, Sym, From, Adjustment);
663 RangeSet RangeGT = getSymGTRange(State, Sym, To, Adjustment);
664 RangeSet New(RangeLT.addRange(F, RangeGT));
665 return New.isEmpty() ? nullptr : State->set<ConstraintRange>(Sym, New);
668 //===------------------------------------------------------------------------===
670 //===------------------------------------------------------------------------===/
672 void RangeConstraintManager::print(ProgramStateRef St, raw_ostream &Out,
673 const char *nl, const char *sep) {
675 ConstraintRangeTy Ranges = St->get<ConstraintRange>();
677 if (Ranges.isEmpty()) {
678 Out << nl << sep << "Ranges are empty." << nl;
682 Out << nl << sep << "Ranges of symbol values:";
683 for (ConstraintRangeTy::iterator I = Ranges.begin(), E = Ranges.end(); I != E;
685 Out << nl << ' ' << I.getKey() << " : ";
686 I.getData().print(Out);