28 for (
size_t I = 0;
I < Length; ++
I) {
30 unsigned char RHC =
toLower(RHS[I]);
32 return LHC < RHC ? -1 : 1;
41 if (Length == RHS.Length)
43 return Length < RHS.Length ? -1 : 1;
48 return Length >= Prefix.Length &&
54 return Length >= Suffix.Length &&
65 for (
size_t I = 0,
E = std::min(Length, RHS.Length);
I !=
E; ++
I) {
71 for (J = I + 1; J !=
E + 1; ++J) {
72 bool ld = J < Length &&
isDigit(Data[J]);
73 bool rd = J < RHS.Length &&
isDigit(RHS.Data[J]);
80 if (
int Res = compareMemory(Data + I, RHS.Data + I, J - I))
81 return Res < 0 ? -1 : 1;
86 if (Data[I] != RHS.Data[I])
87 return (
unsigned char)Data[
I] < (
unsigned char)RHS.Data[I] ? -1 : 1;
89 if (Length == RHS.Length)
91 return Length < RHS.Length ? -1 : 1;
96 bool AllowReplacements,
97 unsigned MaxEditDistance)
const {
101 AllowReplacements, MaxEditDistance);
109 std::string Result(
size(),
char());
117 std::string Result(
size(),
char());
137 const char *Start = Data +
From;
140 const char *Needle = Str.
data();
141 size_t N = Str.
size();
147 const char *Ptr = (
const char *)::memchr(Start, Needle[0], Size);
148 return Ptr ==
nullptr ?
npos : Ptr - Data;
151 const char *Stop = Start + (Size - N + 1);
154 if (Size < 16 || N > 255) {
159 }
while (Start < Stop);
164 uint8_t BadCharSkip[256];
166 for (
unsigned i = 0; i != N-1; ++i)
167 BadCharSkip[(uint8_t)Str[i]] = N-1-i;
170 uint8_t Last = Start[N - 1];
176 Start += BadCharSkip[Last];
177 }
while (Start < Stop);
194 From = std::min(From, Length);
209 size_t N = Str.
size();
212 for (
size_t i = Length - N + 1, e = 0; i != e;) {
221 size_t N = Str.
size();
224 for (
size_t i = Length - N + 1, e = 0; i != e;) {
238 std::bitset<1 << CHAR_BIT> CharBits;
240 CharBits.set((
unsigned char)Chars[i]);
242 for (
size_type i = std::min(From, Length), e = Length; i != e; ++i)
243 if (CharBits.test((
unsigned char)Data[i]))
251 for (
size_type i = std::min(From, Length), e = Length; i != e; ++i)
263 std::bitset<1 << CHAR_BIT> CharBits;
265 CharBits.set((
unsigned char)Chars[i]);
267 for (
size_type i = std::min(From, Length), e = Length; i != e; ++i)
268 if (!CharBits.test((
unsigned char)Data[i]))
279 std::bitset<1 << CHAR_BIT> CharBits;
281 CharBits.set((
unsigned char)Chars[i]);
283 for (
size_type i = std::min(From, Length) - 1, e = -1; i != e; --i)
284 if (CharBits.test((
unsigned char)Data[i]))
292 for (
size_type i = std::min(From, Length) - 1, e = -1; i != e; --i)
304 std::bitset<1 << CHAR_BIT> CharBits;
306 CharBits.set((
unsigned char)Chars[i]);
308 for (
size_type i = std::min(From, Length) - 1, e = -1; i != e; --i)
309 if (!CharBits.test((
unsigned char)Data[i]))
316 bool KeepEmpty)
const {
323 while (MaxSplit-- != 0) {
324 size_t Idx = S.
find(Separator);
329 if (KeepEmpty || Idx > 0)
337 if (KeepEmpty || !S.
empty())
342 int MaxSplit,
bool KeepEmpty)
const {
349 while (MaxSplit-- != 0) {
350 size_t Idx = S.
find(Separator);
355 if (KeepEmpty || Idx > 0)
363 if (KeepEmpty || !S.
empty())
375 size_t N = Str.
size();
378 for (
size_t i = 0, e = Length - N + 1; i != e; ++i)
403 if (Str[0] ==
'0' && Str.
size() > 1 &&
isDigit(Str[1])) {
412 unsigned long long &Result) {
418 if (Str.
empty())
return true;
423 while (!Str2.
empty()) {
425 if (Str2[0] >=
'0' && Str2[0] <=
'9')
426 CharVal = Str2[0] -
'0';
427 else if (Str2[0] >=
'a' && Str2[0] <=
'z')
428 CharVal = Str2[0] -
'a' + 10;
429 else if (Str2[0] >=
'A' && Str2[0] <=
'Z')
430 CharVal = Str2[0] -
'A' + 10;
436 if (CharVal >= Radix)
440 unsigned long long PrevResult = Result;
441 Result = Result * Radix + CharVal;
444 if (Result / Radix < PrevResult)
461 unsigned long long ULLVal;
467 (
long long)ULLVal < 0)
479 (
long long)-ULLVal > 0)
490 unsigned long long &Result) {
516 assert(Radix > 1 && Radix <= 36);
519 if (Str.
empty())
return true;
528 Result =
APInt(64, 0);
533 unsigned Log2Radix = 0;
534 while ((1U << Log2Radix) < Radix) Log2Radix++;
535 bool IsPowerOf2Radix = ((1U << Log2Radix) == Radix);
537 unsigned BitWidth = Log2Radix * Str.
size();
541 Result = Result.
zext(BitWidth);
543 APInt RadixAP, CharAP;
544 if (!IsPowerOf2Radix) {
546 RadixAP =
APInt(BitWidth, Radix);
547 CharAP =
APInt(BitWidth, 0);
552 while (!Str.
empty()) {
554 if (Str[0] >=
'0' && Str[0] <=
'9')
555 CharVal = Str[0]-
'0';
556 else if (Str[0] >=
'a' && Str[0] <=
'z')
557 CharVal = Str[0]-
'a'+10;
558 else if (Str[0] >=
'A' && Str[0] <=
'Z')
559 CharVal = Str[0]-
'A'+10;
565 if (CharVal >= Radix)
569 if (IsPowerOf2Radix) {
570 Result <<= Log2Radix;
LLVM_NODISCARD bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
This class represents lattice values for constants.
unsigned ComputeEditDistance(ArrayRef< T > FromArray, ArrayRef< T > ToArray, bool AllowReplacements=true, unsigned MaxEditDistance=0)
Determine the edit distance between two sequences.
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find_if(function_ref< bool(char)> F, size_t From=0) const
Search for the first character satisfying the predicate F.
bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result)
LLVM_NODISCARD size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
void push_back(const T &Elt)
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
APInt zext(unsigned width) const
Zero extend to a new width.
LLVM_NODISCARD size_t find_last_of(char C, size_t From=npos) const
Find the last character in the string that is C, or npos if not found.
LLVM_NODISCARD bool endswith_lower(StringRef Suffix) const
Check if this string ends with the given Suffix, ignoring case.
LLVM_NODISCARD unsigned edit_distance(StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
Determine the edit distance between this string and another string.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
unsigned getBitWidth() const
Return the number of bits in the APInt.
#define LLVM_UNLIKELY(EXPR)
opStatus convertFromString(StringRef, roundingMode)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
This file implements a class to represent arbitrary precision integral constant values and operations...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD std::string upper() const
Convert the given ASCII string to uppercase.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
double convertToDouble() const
This file declares a class to represent arbitrary precision floating point values and provide a varie...
LLVM_NODISCARD size_t rfind_lower(char C, size_t From=npos) const
Search for the last character C in the string, ignoring case.
static int ascii_strncasecmp(const char *LHS, const char *RHS, size_t Length)
char toLower(char x)
Returns the corresponding lowercase character if x is uppercase.
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
LLVM_NODISCARD int compare_lower(StringRef RHS) const
compare_lower - Compare two strings, ignoring case.
BlockVerifier::State From
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsDouble(double &Result, bool AllowInexact=true) const
Parse the current string as an IEEE double-precision floating point value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
LLVM_NODISCARD size_t find_lower(char C, size_t From=0) const
Search for the first character C in the string, ignoring case.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
LLVM_NODISCARD size_t find_last_not_of(char C, size_t From=npos) const
Find the last character in the string that is not C, or npos if not found.
static unsigned GetAutoSenseRadix(StringRef &Str)
Class for arbitrary precision integers.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
An opaque object representing a hash code.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
LLVM_NODISCARD int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
opStatus
IEEE-754R 7: Default exception handling.
bool isDigit(char C)
Checks if character C is one of the 10 decimal digits.
Merge contiguous icmps into a memcmp
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
LLVM_NODISCARD std::string lower() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
char toUpper(char x)
Returns the corresponding uppercase character if x is lowercase.
LLVM_NODISCARD char front() const
front - Get the first character in the string.
StringRef - Represent a constant reference to a string, i.e.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result)
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)