24 if (x >=
'A' && x <=
'Z')
30 if (x >=
'a' && x <=
'z')
36 return x >=
'0' && x <=
'9';
42 for (
size_t I = 0;
I < Length; ++
I) {
46 return LHC < RHC ? -1 : 1;
55 if (Length == RHS.Length)
57 return Length < RHS.Length ? -1 : 1;
62 return Length >= Prefix.Length &&
68 return Length >= Suffix.Length &&
79 for (
size_t I = 0,
E =
std::min(Length, RHS.Length);
I !=
E; ++
I) {
85 for (J = I + 1; J !=
E + 1; ++J) {
94 if (
int Res = compareMemory(Data + I, RHS.Data + I, J - I))
95 return Res < 0 ? -1 : 1;
100 if (Data[I] != RHS.Data[I])
101 return (
unsigned char)Data[
I] < (
unsigned char)RHS.Data[I] ? -1 : 1;
103 if (Length == RHS.Length)
105 return Length < RHS.Length ? -1 : 1;
110 bool AllowReplacements,
111 unsigned MaxEditDistance)
const {
115 AllowReplacements, MaxEditDistance);
123 std::string Result(
size(),
char());
131 std::string Result(
size(),
char());
151 const char *Start = Data + From;
152 size_t Size = Length - From;
154 const char *Needle = Str.
data();
155 size_t N = Str.
size();
161 const char *
Ptr = (
const char *)::memchr(Start, Needle[0], Size);
162 return Ptr ==
nullptr ?
npos : Ptr - Data;
165 const char *Stop = Start + (Size - N + 1);
168 if (Size < 16 || N > 255) {
170 if (std::memcmp(Start, Needle, N) == 0)
173 }
while (Start < Stop);
178 uint8_t BadCharSkip[256];
179 std::memset(BadCharSkip, N, 256);
180 for (
unsigned i = 0;
i != N-1; ++
i)
181 BadCharSkip[(uint8_t)Str[
i]] = N-1-
i;
184 uint8_t Last = Start[N - 1];
186 if (std::memcmp(Start, Needle, N - 1) == 0)
190 Start += BadCharSkip[Last];
191 }
while (Start < Stop);
223 size_t N = Str.
size();
226 for (
size_t i = Length - N + 1, e = 0;
i != e;) {
235 size_t N = Str.
size();
238 for (
size_t i = Length - N + 1, e = 0;
i != e;) {
252 std::bitset<1 << CHAR_BIT> CharBits;
254 CharBits.set((
unsigned char)Chars[
i]);
257 if (CharBits.test((
unsigned char)Data[i]))
277 std::bitset<1 << CHAR_BIT> CharBits;
279 CharBits.set((
unsigned char)Chars[
i]);
282 if (!CharBits.test((
unsigned char)Data[i]))
293 std::bitset<1 << CHAR_BIT> CharBits;
295 CharBits.set((
unsigned char)Chars[
i]);
298 if (CharBits.test((
unsigned char)Data[i]))
318 std::bitset<1 << CHAR_BIT> CharBits;
320 CharBits.set((
unsigned char)Chars[
i]);
323 if (!CharBits.test((
unsigned char)Data[i]))
330 bool KeepEmpty)
const {
337 while (MaxSplit-- != 0) {
338 size_t Idx = S.
find(Separator);
343 if (KeepEmpty || Idx > 0)
351 if (KeepEmpty || !S.
empty())
356 int MaxSplit,
bool KeepEmpty)
const {
363 while (MaxSplit-- != 0) {
364 size_t Idx = S.
find(Separator);
369 if (KeepEmpty || Idx > 0)
377 if (KeepEmpty || !S.
empty())
389 size_t N = Str.
size();
392 for (
size_t i = 0, e = Length - N + 1;
i != e; ++
i)
426 unsigned long long &Result) {
432 if (Str.
empty())
return true;
437 while (!Str2.
empty()) {
439 if (Str2[0] >=
'0' && Str2[0] <=
'9')
440 CharVal = Str2[0] -
'0';
441 else if (Str2[0] >=
'a' && Str2[0] <=
'z')
442 CharVal = Str2[0] -
'a' + 10;
443 else if (Str2[0] >=
'A' && Str2[0] <=
'Z')
444 CharVal = Str2[0] -
'A' + 10;
450 if (CharVal >= Radix)
454 unsigned long long PrevResult = Result;
455 Result = Result * Radix + CharVal;
458 if (Result / Radix < PrevResult)
475 unsigned long long ULLVal;
481 (
long long)ULLVal < 0)
493 (
long long)-ULLVal > 0)
504 unsigned long long &Result) {
530 assert(Radix > 1 && Radix <= 36);
533 if (Str.
empty())
return true;
542 Result =
APInt(64, 0);
547 unsigned Log2Radix = 0;
548 while ((1U << Log2Radix) < Radix) Log2Radix++;
549 bool IsPowerOf2Radix = ((1U << Log2Radix) == Radix);
551 unsigned BitWidth = Log2Radix * Str.
size();
555 Result = Result.
zext(BitWidth);
557 APInt RadixAP, CharAP;
558 if (!IsPowerOf2Radix) {
560 RadixAP =
APInt(BitWidth, Radix);
561 CharAP =
APInt(BitWidth, 0);
566 while (!Str.
empty()) {
568 if (Str[0] >=
'0' && Str[0] <=
'9')
569 CharVal = Str[0]-
'0';
570 else if (Str[0] >=
'a' && Str[0] <=
'z')
571 CharVal = Str[0]-
'a'+10;
572 else if (Str[0] >=
'A' && Str[0] <=
'Z')
573 CharVal = Str[0]-
'A'+10;
579 if (CharVal >= Radix)
583 if (IsPowerOf2Radix) {
584 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)
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.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
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.
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 etc Experimental Use value profile to guide fuzzing Number of simultaneous worker processes to run the jobs If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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).
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 GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
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.
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)
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
LLVM_NODISCARD std::string lower() const
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)