13 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H 14 #define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H 27 class Range :
public std::pair<const llvm::APSInt *, const llvm::APSInt *> {
29 Range(
const llvm::APSInt &from,
const llvm::APSInt &to)
30 :
std::pair<const
llvm::APSInt *, const
llvm::APSInt *>(&from, &to) {
34 return *first <= v && v <= *second;
36 const llvm::APSInt &
From()
const {
return *first; }
37 const llvm::APSInt &
To()
const {
return *second; }
43 ID.AddPointer(&
From());
48 class RangeTrait :
public llvm::ImutContainerInfo<Range> {
54 static inline bool isLess(key_type_ref lhs, key_type_ref rhs) {
55 return *lhs.first < *rhs.first ||
56 (!(*rhs.first < *lhs.first) && *lhs.second < *rhs.second);
64 typedef llvm::ImmutableSet<Range, RangeTrait> PrimRangeSet;
77 PrimRangeSet Ranges(RS.ranges);
78 for (
const auto &
range : ranges)
79 Ranges = F.add(Ranges,
range);
83 iterator
begin()
const {
return ranges.begin(); }
84 iterator
end()
const {
return ranges.end(); }
86 bool isEmpty()
const {
return ranges.isEmpty(); }
89 RangeSet(Factory &F,
const llvm::APSInt &from,
const llvm::APSInt &to)
90 : ranges(F.add(F.getEmptySet(),
Range(from, to))) {}
94 void Profile(llvm::FoldingSetNodeID &
ID)
const { ranges.Profile(ID); }
100 return ranges.isSingleton() ? ranges.begin()->getConcreteValue() :
nullptr;
105 const llvm::APSInt &Lower,
const llvm::APSInt &Upper,
106 PrimRangeSet &newRanges, PrimRangeSet::iterator &
i,
107 PrimRangeSet::iterator &e)
const;
109 const llvm::APSInt &getMinValue()
const;
111 bool pin(llvm::APSInt &Lower, llvm::APSInt &Upper)
const;
115 llvm::APSInt Upper)
const;
120 void print(raw_ostream &os)
const;
123 return ranges == other.ranges;
134 static void *GDMIndex();
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
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
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)