LLVM 22.0.0git
llvm::IntegerInclusiveIntervalUtils Namespace Reference

Typedefs

using IntervalList = SmallVector<IntegerInclusiveInterval, 8>
 A list of integer intervals.

Functions

Expected< IntervalListparseIntervals (StringRef IntervalStr, char Separator=',')
 Parse a interval specification string like "1-10,20-30,45" or "1-10:20-30:45".
bool contains (ArrayRef< IntegerInclusiveInterval > Intervals, int64_t Value)
 Check if a value is contained in any of the intervals.
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.

Typedef Documentation

◆ IntervalList

A list of integer intervals.

Definition at line 82 of file IntegerInclusiveInterval.h.

Function Documentation

◆ contains()

bool llvm::IntegerInclusiveIntervalUtils::contains ( ArrayRef< IntegerInclusiveInterval > Intervals,
int64_t Value )

Check if a value is contained in any of the intervals.

Definition at line 78 of file IntegerInclusiveInterval.cpp.

Referenced by llvm::OptBisect::shouldRunPass().

◆ mergeAdjacentIntervals()

IntervalList llvm::IntegerInclusiveIntervalUtils::mergeAdjacentIntervals ( ArrayRef< IntegerInclusiveInterval > Intervals)

Merge adjacent/consecutive intervals into single intervals.

Example: [1-3, 4-6, 8-10] -> [1-6, 8-10].

Definition at line 103 of file IntegerInclusiveInterval.cpp.

References llvm::ArrayRef< T >::drop_front(), llvm::ArrayRef< T >::empty(), and llvm::Last.

◆ parseIntervals()

Expected< IntervalList > llvm::IntegerInclusiveIntervalUtils::parseIntervals ( StringRef IntervalStr,
char Separator = ',' )

Parse a interval specification string like "1-10,20-30,45" or "1-10:20-30:45".

Intervals must be in increasing order and non-overlapping.

Parameters
IntervalStrThe string to parse.
SeparatorThe separator character to use (',' or ':').
Returns
Expected<IntervalList> containing the parsed intervals on success, or an Error on failure.

Definition at line 26 of file IntegerInclusiveInterval.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::c_str(), llvm::createStringError(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::Regex::match(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::split().

Referenced by llvm::DebugCounter::push_back().

◆ printIntervals()

void llvm::IntegerInclusiveIntervalUtils::printIntervals ( raw_ostream & OS,
ArrayRef< IntegerInclusiveInterval > Intervals,
char Separator = ',' )

Print intervals to output stream.

Parameters
OSThe output stream to print to.
IntervalsThe intervals to print.
SeparatorThe separator character to use between intervals (i.e. ',' or ':').

Definition at line 86 of file IntegerInclusiveInterval.cpp.

References llvm::ArrayRef< T >::empty().

Referenced by llvm::DebugCounter::printChunks().