14 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H 15 #define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H 28 class Range :
public std::pair<const llvm::APSInt *, const llvm::APSInt *> {
30 Range(
const llvm::APSInt &from,
const llvm::APSInt &to)
31 :
std::pair<const
llvm::APSInt *, const
llvm::APSInt *>(&from, &to) {
35 return *first <= v && v <= *second;
37 const llvm::APSInt &
From()
const {
return *first; }
38 const llvm::APSInt &
To()
const {
return *second; }
44 ID.AddPointer(&
From());
49 class RangeTrait :
public llvm::ImutContainerInfo<Range> {
55 static inline bool isLess(key_type_ref lhs, key_type_ref rhs) {
56 return *lhs.first < *rhs.first ||
57 (!(*rhs.first < *lhs.first) && *lhs.second < *rhs.second);
65 typedef llvm::ImmutableSet<Range, RangeTrait> PrimRangeSet;
78 PrimRangeSet Ranges(RS.ranges);
79 for (
const auto &range : ranges)
80 Ranges = F.add(Ranges, range);
84 iterator
begin()
const {
return ranges.begin(); }
85 iterator
end()
const {
return ranges.end(); }
87 bool isEmpty()
const {
return ranges.isEmpty(); }
90 RangeSet(Factory &F,
const llvm::APSInt &from,
const llvm::APSInt &to)
91 : ranges(F.add(F.getEmptySet(),
Range(from, to))) {}
95 void Profile(llvm::FoldingSetNodeID &
ID)
const { ranges.Profile(ID); }
101 return ranges.isSingleton() ? ranges.begin()->getConcreteValue() :
nullptr;
106 const llvm::APSInt &Lower,
const llvm::APSInt &Upper,
107 PrimRangeSet &newRanges, PrimRangeSet::iterator &i,
108 PrimRangeSet::iterator &e)
const;
110 const llvm::APSInt &getMinValue()
const;
112 bool pin(llvm::APSInt &Lower, llvm::APSInt &Upper)
const;
116 llvm::APSInt Upper)
const;
120 void print(raw_ostream &os)
const;
123 return ranges == other.ranges;
134 static void *
GDMIndex() {
static int Index;
return &Index; }
150 bool Assumption)
override;
153 const llvm::APSInt &
From,
154 const llvm::APSInt &
To,
155 bool InRange)
override;
158 bool Assumption)
override;
164 const llvm::APSInt &Int);
174 const llvm::APSInt &V,
175 const llvm::APSInt &Adjustment) = 0;
178 const llvm::APSInt &V,
179 const llvm::APSInt &Adjustment) = 0;
182 const llvm::APSInt &V,
183 const llvm::APSInt &Adjustment) = 0;
186 const llvm::APSInt &V,
187 const llvm::APSInt &Adjustment) = 0;
190 const llvm::APSInt &V,
191 const llvm::APSInt &Adjustment) = 0;
194 const llvm::APSInt &V,
195 const llvm::APSInt &Adjustment) = 0;
199 const llvm::APSInt &To,
const llvm::APSInt &Adjustment) = 0;
203 const llvm::APSInt &To,
const llvm::APSInt &Adjustment) = 0;
209 static void computeAdjustment(
SymbolRef &Sym, llvm::APSInt &Adjustment);
const llvm::APSInt & From() const
void Profile(llvm::FoldingSetNodeID &ID) const
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
A Range represents the closed range [from, to].
llvm::ImmutableMap< SymbolRef, RangeSet > ConstraintRangeTy
RangeSet contains a set of ranges.
static bool isLess(key_type_ref lhs, key_type_ref rhs)
Range(const llvm::APSInt &from, const llvm::APSInt &to)
RangeSet addRange(Factory &F, const RangeSet &RS)
Create a new set with all ranges of this set and RS.
PrimRangeSet::Factory Factory
RangeSet(Factory &F, const llvm::APSInt &from, const llvm::APSInt &to)
Construct a new RangeSet representing '{ [from, to] }'.
const llvm::APSInt * getConcreteValue() const
const llvm::APSInt * getConcreteValue() const
getConcreteValue - If a symbol is contrained to equal a specific integer constant then this method re...
bool Includes(const llvm::APSInt &v) const
void Profile(llvm::FoldingSetNodeID &ID) const
Profile - Generates a hash profile of this RangeSet for use by FoldingSet.
bool operator==(const RangeSet &other) const
Dataflow Directional Tag Classes.
RangeSet(PrimRangeSet RS)
const llvm::APSInt & To() const
PrimRangeSet::iterator iterator
RangedConstraintManager(SubEngine *SE, SValBuilder &SB)
static llvm::ImmutableListFactory< const FieldRegion * > Factory