[llvm] [ADT][NFC] Make `getAutoSenseRadix` in `StringRef` global (PR #152503)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 07:03:40 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Ilia Kuklin (kuilpd)
<details>
<summary>Changes</summary>
Needed in #<!-- -->152308
---
Full diff: https://github.com/llvm/llvm-project/pull/152503.diff
2 Files Affected:
- (modified) llvm/include/llvm/ADT/StringRef.h (+2)
- (modified) llvm/lib/Support/StringRef.cpp (+3-3)
``````````diff
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 0ced1c0379a3b..16aca4d45892d 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -38,6 +38,8 @@ namespace llvm {
LLVM_ABI bool getAsSignedInteger(StringRef Str, unsigned Radix,
long long &Result);
+ LLVM_ABI unsigned getAutoSenseRadix(StringRef &Str);
+
LLVM_ABI bool consumeUnsignedInteger(StringRef &Str, unsigned Radix,
unsigned long long &Result);
LLVM_ABI bool consumeSignedInteger(StringRef &Str, unsigned Radix,
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index dc758785e40d5..b6a2f8aeadccf 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -385,7 +385,7 @@ size_t StringRef::count(StringRef Str) const {
return Count;
}
-static unsigned GetAutoSenseRadix(StringRef &Str) {
+unsigned llvm::getAutoSenseRadix(StringRef &Str) {
if (Str.empty())
return 10;
@@ -410,7 +410,7 @@ bool llvm::consumeUnsignedInteger(StringRef &Str, unsigned Radix,
unsigned long long &Result) {
// Autosense radix if not specified.
if (Radix == 0)
- Radix = GetAutoSenseRadix(Str);
+ Radix = getAutoSenseRadix(Str);
// Empty strings (after the radix autosense) are invalid.
if (Str.empty()) return true;
@@ -509,7 +509,7 @@ bool StringRef::consumeInteger(unsigned Radix, APInt &Result) {
// Autosense radix if not specified.
if (Radix == 0)
- Radix = GetAutoSenseRadix(Str);
+ Radix = getAutoSenseRadix(Str);
assert(Radix > 1 && Radix <= 36);
``````````
</details>
https://github.com/llvm/llvm-project/pull/152503
More information about the llvm-commits
mailing list