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 &&
74 for (
size_t I = 0, E =
std::min(Length, RHS.Length);
I != E; ++
I) {
80 for (J = I + 1; J != E + 1; ++J) {
89 if (
int Res = compareMemory(Data + I, RHS.Data + I, J - I))
90 return Res < 0 ? -1 : 1;
95 if (Data[I] != RHS.Data[I])
96 return (
unsigned char)Data[
I] < (
unsigned char)RHS.Data[I] ? -1 : 1;
98 if (Length == RHS.Length)
100 return Length < RHS.Length ? -1 : 1;
105 bool AllowReplacements,
106 unsigned MaxEditDistance)
const {
110 AllowReplacements, MaxEditDistance);
118 std::string Result(
size(),
char());
126 std::string Result(
size(),
char());
143 size_t N = Str.
size();
148 if (Length < 16 || N > 255 || N == 0) {
149 for (
size_t e = Length - N + 1, i =
std::min(From, e); i != e; ++i)
159 uint8_t BadCharSkip[256];
160 std::memset(BadCharSkip, N, 256);
161 for (
unsigned i = 0; i != N-1; ++i)
162 BadCharSkip[(uint8_t)Str[i]] = N-1-i;
164 unsigned Len = Length-From, Pos = From;
170 uint8_t Skip = BadCharSkip[(uint8_t)(*
this)[Pos+N-1]];
183 size_t N = Str.
size();
186 for (
size_t i = Length - N + 1, e = 0; i != e;) {
200 std::bitset<1 << CHAR_BIT> CharBits;
202 CharBits.set((
unsigned char)Chars[i]);
205 if (CharBits.test((
unsigned char)Data[i]))
225 std::bitset<1 << CHAR_BIT> CharBits;
227 CharBits.set((
unsigned char)Chars[i]);
230 if (!CharBits.test((
unsigned char)Data[i]))
241 std::bitset<1 << CHAR_BIT> CharBits;
243 CharBits.set((
unsigned char)Chars[i]);
246 if (CharBits.test((
unsigned char)Data[i]))
266 std::bitset<1 << CHAR_BIT> CharBits;
268 CharBits.set((
unsigned char)Chars[i]);
271 if (!CharBits.test((
unsigned char)Data[i]))
278 bool KeepEmpty)
const {
284 rest.
data() !=
nullptr && (MaxSplit < 0 || splits < MaxSplit);
286 std::pair<StringRef, StringRef> p = rest.
split(Separators);
288 if (KeepEmpty || p.first.size() != 0)
293 if (rest.
data() !=
nullptr && (rest.
size() != 0 || KeepEmpty))
305 size_t N = Str.
size();
308 for (
size_t i = 0, e = Length - N + 1; i != e; ++i)
340 unsigned long long &Result) {
346 if (Str.
empty())
return true;
350 while (!Str.
empty()) {
352 if (Str[0] >=
'0' && Str[0] <=
'9')
353 CharVal = Str[0]-
'0';
354 else if (Str[0] >=
'a' && Str[0] <=
'z')
355 CharVal = Str[0]-
'a'+10;
356 else if (Str[0] >=
'A' && Str[0] <=
'Z')
357 CharVal = Str[0]-
'A'+10;
363 if (CharVal >= Radix)
367 unsigned long long PrevResult = Result;
368 Result = Result*Radix+CharVal;
371 if (Result/Radix < PrevResult)
382 unsigned long long ULLVal;
388 (
long long)ULLVal < 0)
399 (
long long)-ULLVal > 0)
413 assert(Radix > 1 && Radix <= 36);
416 if (Str.
empty())
return true;
425 Result =
APInt(64, 0);
430 unsigned Log2Radix = 0;
431 while ((1U << Log2Radix) < Radix) Log2Radix++;
432 bool IsPowerOf2Radix = ((1U << Log2Radix) == Radix);
434 unsigned BitWidth = Log2Radix * Str.
size();
438 Result = Result.
zext(BitWidth);
440 APInt RadixAP, CharAP;
441 if (!IsPowerOf2Radix) {
443 RadixAP =
APInt(BitWidth, Radix);
444 CharAP =
APInt(BitWidth, 0);
449 while (!Str.
empty()) {
451 if (Str[0] >=
'0' && Str[0] <=
'9')
452 CharVal = Str[0]-
'0';
453 else if (Str[0] >=
'a' && Str[0] <=
'z')
454 CharVal = Str[0]-
'a'+10;
455 else if (Str[0] >=
'A' && Str[0] <=
'Z')
456 CharVal = Str[0]-
'A'+10;
462 if (CharVal >= Radix)
466 if (IsPowerOf2Radix) {
467 Result <<= Log2Radix;
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)
int compare_lower(StringRef RHS) const
compare_lower - Compare two strings, ignoring case.
size_t size() const
size - Get the string size.
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.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
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.
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
This file implements a class to represent arbitrary precision integral constant values and operations...
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
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.
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.
static int ascii_strncasecmp(const char *LHS, const char *RHS, size_t Length)
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.
unsigned edit_distance(StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
Determine the edit distance between this string and another string.
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.
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
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.
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.
bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
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.
static bool ascii_isdigit(char x)
char front() const
front - Get the first character in the string.
int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
StringRef - Represent a constant reference to a string, i.e.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT zext(unsigned width) const
Zero extend to a new width.
bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
std::string lower() const
bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result)
bool empty() const
empty - Check if the string is empty.