30 return std::move(Intervals);
33 const Regex IntervalRegex(
"^([0-9]+)(-([0-9]+))?$");
41 if (!IntervalRegex.
match(Part, &Matches))
43 "Invalid interval format: '%s'",
47 if (Matches[1].getAsInteger(10, Begin))
49 "Failed to parse number: '%s'",
50 Matches[1].str().
c_str());
52 if (!Matches[3].empty()) {
54 if (Matches[3].getAsInteger(10, End))
56 "Failed to parse number: '%s'",
57 Matches[3].str().
c_str());
60 "Invalid interval: %lld >= %lld", Begin, End);
66 if (!Intervals.
empty() && Begin <= Intervals.
back().getEnd())
68 std::errc::invalid_argument,
69 "Expected intervals to be in increasing order: %lld <= %lld", Begin,
70 Intervals.
back().getEnd());
80 if (It.contains(
Value))
89 if (Intervals.
empty()) {
94 std::string Sep(1, Separator);
104 if (Intervals.
empty())
108 Result.push_back(Intervals[0]);
113 if (Current.getBegin() ==
Last.getEnd() + 1) {
115 Last.setEnd(Current.getEnd());
118 Result.push_back(Current);
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
bool empty() const
empty - Check if the array is empty.
Tagged union holding either a T or a Error.
Represents an inclusive integer interval [Begin, End] where Begin <= End.
A helper class to return the specified delimiter string after the first invocation of operator String...
LLVM_ABI bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
void printIntervals(raw_ostream &OS, ArrayRef< IntegerInclusiveInterval > Intervals, char Separator=',')
Print intervals to output stream.
IntervalList mergeAdjacentIntervals(ArrayRef< IntegerInclusiveInterval > Intervals)
Merge adjacent/consecutive intervals into single intervals.
bool contains(ArrayRef< IntegerInclusiveInterval > Intervals, int64_t Value)
Check if a value is contained in any of the intervals.
SmallVector< IntegerInclusiveInterval, 8 > IntervalList
A list of integer intervals.
Expected< IntervalList > parseIntervals(StringRef IntervalStr, char Separator=',')
Parse a interval specification string like "1-10,20-30,45" or "1-10:20-30:45".
This is an optimization pass for GlobalISel generic memory operations.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
iterator_range< SplittingIterator > split(StringRef Str, StringRef Separator)
Split the specified string over a separator and return a range-compatible iterable over its partition...