aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-01-11 22:48:20 -0800
committerKazu Hirata <kazu@google.com>2024-01-11 22:48:20 -0800
commit5e9da33b8743d13e29be1350e357f2d527a417dd (patch)
tree4930ad5fc8d3f0e606d369824bc297bf82b5d081 /llvm/lib/Support/StringRef.cpp
parentbfb026e17ce288cd446d19f5d6329d08b4f46e04 (diff)
downloadllvm-5e9da33b8743d13e29be1350e357f2d527a417dd.zip
llvm-5e9da33b8743d13e29be1350e357f2d527a417dd.tar.gz
llvm-5e9da33b8743d13e29be1350e357f2d527a417dd.tar.bz2
[llvm] Use StringRef::consume_front_insensitive (NFC)
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r--llvm/lib/Support/StringRef.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index feee47c..decd06a 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -388,20 +388,14 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
if (Str.empty())
return 10;
- if (Str.starts_with("0x") || Str.starts_with("0X")) {
- Str = Str.substr(2);
+ if (Str.consume_front_insensitive("0x"))
return 16;
- }
- if (Str.starts_with("0b") || Str.starts_with("0B")) {
- Str = Str.substr(2);
+ if (Str.consume_front_insensitive("0b"))
return 2;
- }
- if (Str.starts_with("0o")) {
- Str = Str.substr(2);
+ if (Str.consume_front("0o"))
return 8;
- }
if (Str[0] == '0' && Str.size() > 1 && isDigit(Str[1])) {
Str = Str.substr(1);