Lines Matching defs:Str
126 /// find - Search for the first string \arg Str in the string.
128 /// \return - The index of the first occurrence of \arg Str, or npos if not
130 size_t StringRef::find(StringRef Str, size_t From) const {
137 const char *Needle = Str.data();
138 size_t N = Str.size();
176 BadCharSkip[(uint8_t)Str[i]] = N-1-i;
191 size_t StringRef::find_insensitive(StringRef Str, size_t From) const {
193 while (This.size() >= Str.size()) {
194 if (This.starts_with_insensitive(Str))
213 /// rfind - Search for the last string \arg Str in the string.
215 /// \return - The index of the last occurrence of \arg Str, or npos if not
217 size_t StringRef::rfind(StringRef Str) const {
218 return std::string_view(*this).rfind(Str);
221 size_t StringRef::rfind_insensitive(StringRef Str) const {
222 size_t N = Str.size();
227 if (substr(i, N).equals_insensitive(Str))
369 /// count - Return the number of non-overlapped occurrences of \arg Str in
371 size_t StringRef::count(StringRef Str) const {
374 size_t N = Str.size();
375 // TODO: For an empty `Str` we return 0 for legacy reasons. Consider changing
380 while ((Pos = find(Str, Pos)) != npos) {
387 static unsigned GetAutoSenseRadix(StringRef &Str) {
388 if (Str.empty())
391 if (Str.consume_front_insensitive("0x"))
394 if (Str.consume_front_insensitive("0b"))
397 if (Str.consume_front("0o"))
400 if (Str[0] == '0' && Str.size() > 1 && isDigit(Str[1])) {
401 Str = Str.substr(1);
408 bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
412 Radix = GetAutoSenseRadix(Str);
415 if (Str.empty()) return true;
418 StringRef Str2 = Str;
449 if (Str.size() == Str2.size())
452 Str = Str2;
456 bool llvm::consumeSignedInteger(StringRef &Str, unsigned Radix,
461 if (!Str.starts_with("-")) {
462 if (consumeUnsignedInteger(Str, Radix, ULLVal) ||
471 StringRef Str2 = Str.drop_front(1);
479 Str = Str2;
486 bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix,
488 if (consumeUnsignedInteger(Str, Radix, Result))
493 return !Str.empty();
496 bool llvm::getAsSignedInteger(StringRef Str, unsigned Radix,
498 if (consumeSignedInteger(Str, Radix, Result))
503 return !Str.empty();
507 StringRef Str = *this;
511 Radix = GetAutoSenseRadix(Str);
516 if (Str.empty()) return true;
520 Str = Str.ltrim('0');
523 if (Str.empty()) {
525 *this = Str;
534 unsigned BitWidth = Log2Radix * Str.size();
549 while (!Str.empty()) {
551 if (Str[0] >= '0' && Str[0] <= '9')
552 CharVal = Str[0]-'0';
553 else if (Str[0] >= 'a' && Str[0] <= 'z')
554 CharVal = Str[0]-'a'+10;
555 else if (Str[0] >= 'A' && Str[0] <= 'Z')
556 CharVal = Str[0]-'A'+10;
575 Str = Str.substr(1);
580 if (size() == Str.size())
583 *this = Str;
588 StringRef Str = *this;
589 if (Str.consumeInteger(Radix, Result))
594 return !Str.empty();