25 if (x >=
'A' && x <=
'Z')
31 if (x >=
'a' && x <=
'z')
37 return x >=
'0' && x <=
'9';
43 for (
size_t I = 0;
I < Length; ++
I) {
47 return LHC < RHC ? -1 : 1;
56 if (Length == RHS.Length)
58 return Length < RHS.Length ? -1 : 1;
63 return Length >= Prefix.Length &&
69 return Length >= Suffix.Length &&
80 for (
size_t I = 0,
E =
std::min(Length, RHS.Length);
I !=
E; ++
I) {
86 for (J = I + 1; J !=
E + 1; ++J) {
95 if (
int Res = compareMemory(Data + I, RHS.Data + I, J - I))
96 return Res < 0 ? -1 : 1;
101 if (Data[I] != RHS.Data[I])
102 return (
unsigned char)Data[
I] < (
unsigned char)RHS.Data[I] ? -1 : 1;
104 if (Length == RHS.Length)
106 return Length < RHS.Length ? -1 : 1;
111 bool AllowReplacements,
112 unsigned MaxEditDistance)
const {
116 AllowReplacements, MaxEditDistance);
124 std::string Result(
size(),
char());
132 std::string Result(
size(),
char());
152 const char *Start = Data + From;
153 size_t Size = Length - From;
155 const char *Needle = Str.
data();
156 size_t N = Str.
size();
162 const char *
Ptr = (
const char *)::memchr(Start, Needle[0], Size);
163 return Ptr ==
nullptr ?
npos : Ptr - Data;
166 const char *Stop = Start + (Size - N + 1);
169 if (Size < 16 || N > 255) {
171 if (std::memcmp(Start, Needle, N) == 0)
174 }
while (Start < Stop);
179 uint8_t BadCharSkip[256];
180 std::memset(BadCharSkip, N, 256);
181 for (
unsigned i = 0; i != N-1; ++i)
182 BadCharSkip[(uint8_t)Str[i]] = N-1-i;
185 uint8_t Last = Start[N - 1];
187 if (std::memcmp(Start, Needle, N - 1) == 0)
191 Start += BadCharSkip[Last];
192 }
while (Start < Stop);
224 size_t N = Str.
size();
227 for (
size_t i = Length - N + 1, e = 0; i != e;) {
236 size_t N = Str.
size();
239 for (
size_t i = Length - N + 1, e = 0; i != e;) {
253 std::bitset<1 << CHAR_BIT> CharBits;
255 CharBits.set((
unsigned char)Chars[i]);
258 if (CharBits.test((
unsigned char)Data[i]))
278 std::bitset<1 << CHAR_BIT> CharBits;
280 CharBits.set((
unsigned char)Chars[i]);
283 if (!CharBits.test((
unsigned char)Data[i]))
294 std::bitset<1 << CHAR_BIT> CharBits;
296 CharBits.set((
unsigned char)Chars[i]);
299 if (CharBits.test((
unsigned char)Data[i]))
319 std::bitset<1 << CHAR_BIT> CharBits;
321 CharBits.set((
unsigned char)Chars[i]);
324 if (!CharBits.test((
unsigned char)Data[i]))
331 bool KeepEmpty)
const {
338 while (MaxSplit-- != 0) {
339 size_t Idx = S.
find(Separator);
344 if (KeepEmpty || Idx > 0)
352 if (KeepEmpty || !S.
empty())
357 int MaxSplit,
bool KeepEmpty)
const {
364 while (MaxSplit-- != 0) {
365 size_t Idx = S.
find(Separator);
370 if (KeepEmpty || Idx > 0)
378 if (KeepEmpty || !S.
empty())
390 size_t N = Str.
size();
393 for (
size_t i = 0, e = Length - N + 1; i != e; ++i)
427 unsigned long long &Result) {
433 if (Str.
empty())
return true;
438 while (!Str2.
empty()) {
440 if (Str2[0] >=
'0' && Str2[0] <=
'9')
441 CharVal = Str2[0] -
'0';
442 else if (Str2[0] >=
'a' && Str2[0] <=
'z')
443 CharVal = Str2[0] -
'a' + 10;
444 else if (Str2[0] >=
'A' && Str2[0] <=
'Z')
445 CharVal = Str2[0] -
'A' + 10;
451 if (CharVal >= Radix)
455 unsigned long long PrevResult = Result;
456 Result = Result * Radix + CharVal;
459 if (Result / Radix < PrevResult)
476 unsigned long long ULLVal;
482 (
long long)ULLVal < 0)
494 (
long long)-ULLVal > 0)
505 unsigned long long &Result) {
531 assert(Radix > 1 && Radix <= 36);
534 if (Str.
empty())
return true;
543 Result =
APInt(64, 0);
548 unsigned Log2Radix = 0;
549 while ((1U << Log2Radix) < Radix) Log2Radix++;
550 bool IsPowerOf2Radix = ((1U << Log2Radix) == Radix);
552 unsigned BitWidth = Log2Radix * Str.
size();
556 Result = Result.
zext(BitWidth);
558 APInt RadixAP, CharAP;
559 if (!IsPowerOf2Radix) {
561 RadixAP =
APInt(BitWidth, Radix);
562 CharAP =
APInt(BitWidth, 0);
567 while (!Str.
empty()) {
569 if (Str[0] >=
'0' && Str[0] <=
'9')
570 CharVal = Str[0]-
'0';
571 else if (Str[0] >=
'a' && Str[0] <=
'z')
572 CharVal = Str[0]-
'a'+10;
573 else if (Str[0] >=
'A' && Str[0] <=
'Z')
574 CharVal = Str[0]-
'A'+10;
580 if (CharVal >= Radix)
584 if (IsPowerOf2Radix) {
585 Result <<= Log2Radix;
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.
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.
void push_back(const T &Elt)
LLVM_NODISCARD int compare_lower(StringRef RHS) const
compare_lower - Compare two strings, ignoring case.
static char ascii_toupper(char x)
unsigned ComputeEditDistance(ArrayRef< T > FromArray, ArrayRef< T > ToArray, bool AllowReplacements=true, unsigned MaxEditDistance=0)
Determine the edit distance between two sequences.
#define LLVM_UNLIKELY(EXPR)
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
bool consumeUnsignedInteger(StringRef &Str, unsigned Radix, unsigned long long &Result)
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
LLVM_NODISCARD size_t rfind_lower(char C, size_t From=npos) const
Search for the last character C in the string, ignoring case.
LLVM_NODISCARD size_t find_lower(char C, size_t From=0) const
Search for the first character C in the string, ignoring case.
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
LLVM_NODISCARD bool endswith_lower(StringRef Suffix) const
Check if this string ends with the given Suffix, ignoring case.
opStatus convertFromString(StringRef, roundingMode)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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 ...
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 StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
LLVM_NODISCARD char front() const
front - Get the first character in the string.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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.
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.
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 LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
This file declares a class to represent arbitrary precision floating point values and provide a varie...
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
unsigned getBitWidth() const
Return the number of bits in the APInt.
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.
static int ascii_strncasecmp(const char *LHS, const char *RHS, size_t Length)
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.
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 size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
static const char * Separator
LLVM_NODISCARD std::string upper() const
Convert the given ASCII string to uppercase.
static char ascii_tolower(char x)
static unsigned GetAutoSenseRadix(StringRef &Str)
Class for arbitrary precision integers.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
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 empty() const
empty - Check if the string is empty.
double convertToDouble() const
bool getAsDouble(double &Result, bool AllowInexact=true) const
Parse the current string as an IEEE double-precision floating point value.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
opStatus
IEEE-754R 7: Default exception handling.
static bool ascii_isdigit(char x)
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_NODISCARD int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
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).
StringRef - Represent a constant reference to a string, i.e.
APInt zext(unsigned width) const
Zero extend to a new width.
LLVM_NODISCARD bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result)
LLVM_NODISCARD std::string lower() const
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)