[llvm] [llvm] Use StringRef::consume_front (NFC) (PR #139458)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 09:44:17 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/139458.diff
2 Files Affected:
- (modified) llvm/lib/Support/APFloat.cpp (+3-7)
- (modified) llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp (+1-3)
``````````diff
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index a7b9f259bfed5..e99649d26ce88 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -3262,9 +3262,8 @@ bool IEEEFloat::convertFromStringSpecials(StringRef str) {
return true;
}
- bool IsNegative = str.front() == '-';
+ bool IsNegative = str.consume_front("-");
if (IsNegative) {
- str = str.drop_front();
if (str.size() < MIN_NAME_SIZE)
return false;
@@ -3275,16 +3274,13 @@ bool IEEEFloat::convertFromStringSpecials(StringRef str) {
}
// If we have a 's' (or 'S') prefix, then this is a Signaling NaN.
- bool IsSignaling = str.front() == 's' || str.front() == 'S';
+ bool IsSignaling = str.consume_front_insensitive("s");
if (IsSignaling) {
- str = str.drop_front();
if (str.size() < MIN_NAME_SIZE)
return false;
}
- if (str.starts_with("nan") || str.starts_with("NaN")) {
- str = str.drop_front(3);
-
+ if (str.consume_front("nan") || str.consume_front("NaN")) {
// A NaN without payload.
if (str.empty()) {
makeNaN(IsSignaling, IsNegative);
diff --git a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
index ad42c73e24333..251828b6bc35b 100644
--- a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
@@ -1632,10 +1632,8 @@ SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVTypeByName(
auto SpirvTy = getOrCreateSPIRVType(Ty, MIRBuilder, AQ, false, true);
// Handle "type*" or "type* vector[N]".
- if (TypeStr.starts_with("*")) {
+ if (TypeStr.consume_front("*"))
SpirvTy = getOrCreateSPIRVPointerType(Ty, MIRBuilder, SC);
- TypeStr = TypeStr.substr(strlen("*"));
- }
// Handle "typeN*" or "type vector[N]*".
bool IsPtrToVec = TypeStr.consume_back("*");
``````````
</details>
https://github.com/llvm/llvm-project/pull/139458
More information about the llvm-commits
mailing list