[llvm] 7470131 - [llvm] Use StringRef::consume_front (NFC) (#139458)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 10:28:52 PDT 2025
Author: Kazu Hirata
Date: 2025-05-11T10:28:49-07:00
New Revision: 7470131b43405a07ccafd83aea286d0f35aefb34
URL: https://github.com/llvm/llvm-project/commit/7470131b43405a07ccafd83aea286d0f35aefb34
DIFF: https://github.com/llvm/llvm-project/commit/7470131b43405a07ccafd83aea286d0f35aefb34.diff
LOG: [llvm] Use StringRef::consume_front (NFC) (#139458)
Added:
Modified:
llvm/lib/Support/APFloat.cpp
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
Removed:
################################################################################
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("*");
More information about the llvm-commits
mailing list