[clang] 5404a37 - [Driver] Use StringRef::consume_front (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 24 00:27:45 PST 2024
Author: Kazu Hirata
Date: 2024-01-24T00:27:33-08:00
New Revision: 5404a3792ed58b94b938bbf5cfe6eeb23c664efc
URL: https://github.com/llvm/llvm-project/commit/5404a3792ed58b94b938bbf5cfe6eeb23c664efc
DIFF: https://github.com/llvm/llvm-project/commit/5404a3792ed58b94b938bbf5cfe6eeb23c664efc.diff
LOG: [Driver] Use StringRef::consume_front (NFC)
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7109faa1072de5f..190a73bfd40b68e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6482,18 +6482,15 @@ bool Driver::GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
return false;
if (Str.empty())
return true;
- if (Str[0] != '.')
+ if (!Str.consume_front("."))
return false;
- Str = Str.drop_front(1);
-
if (Str.consumeInteger(10, Minor))
return false;
if (Str.empty())
return true;
- if (Str[0] != '.')
+ if (!Str.consume_front("."))
return false;
- Str = Str.drop_front(1);
if (Str.consumeInteger(10, Micro))
return false;
@@ -6521,9 +6518,8 @@ bool Driver::GetReleaseVersion(StringRef Str,
Digits[CurDigit] = Digit;
if (Str.empty())
return true;
- if (Str[0] != '.')
+ if (!Str.consume_front("."))
return false;
- Str = Str.drop_front(1);
CurDigit++;
}
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index fadaf3e60c6616a..48534bc1669e44d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -317,9 +317,7 @@ void tools::handleTargetFeaturesGroup(const Driver &D,
continue;
}
- bool IsNegative = Name.starts_with("no-");
- if (IsNegative)
- Name = Name.substr(3);
+ bool IsNegative = Name.consume_front("no-");
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
}
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index d1eed931be5f1ee..8a5f8f148993192 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -801,7 +801,6 @@ StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
CpuArg = A;
StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
- if (CPU.starts_with("hexagon"))
- return CPU.substr(sizeof("hexagon") - 1);
+ CPU.consume_front("hexagon");
return CPU;
}
More information about the cfe-commits
mailing list