[clang] fe35d72 - [Driver] Use StringRef::consume_back (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 26 23:46:40 PST 2024
Author: Kazu Hirata
Date: 2024-01-26T23:46:29-08:00
New Revision: fe35d72d8e248f1d29f9c5e503463bb1c4d6f8c6
URL: https://github.com/llvm/llvm-project/commit/fe35d72d8e248f1d29f9c5e503463bb1c4d6f8c6
DIFF: https://github.com/llvm/llvm-project/commit/fe35d72d8e248f1d29f9c5e503463bb1c4d6f8c6.diff
LOG: [Driver] Use StringRef::consume_back (NFC)
Added:
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Flang.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8092fc050b0ee6d..8d8965fdf76fb8a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1747,9 +1747,7 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
Val.equals("2048+")) {
unsigned Bits = 0;
- if (Val.ends_with("+"))
- Val = Val.substr(0, Val.size() - 1);
- else {
+ if (!Val.consume_back("+")) {
bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
assert(!Invalid && "Failed to parse value");
CmdArgs.push_back(
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 03d68c3df7fb374..b659521df88ff98 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -185,9 +185,7 @@ void Flang::AddAArch64TargetArgs(const ArgList &Args,
Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
Val.equals("2048+")) {
unsigned Bits = 0;
- if (Val.ends_with("+"))
- Val = Val.substr(0, Val.size() - 1);
- else {
+ if (!Val.consume_back("+")) {
[[maybe_unused]] bool Invalid = Val.getAsInteger(10, Bits);
assert(!Invalid && "Failed to parse value");
CmdArgs.push_back(
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 8a5f8f148993192..fa47c98901e1453 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -54,8 +54,7 @@ static void handleHVXTargetFeatures(const Driver &D, const ArgList &Args,
auto makeFeature = [&Args](Twine T, bool Enable) -> StringRef {
const std::string &S = T.str();
StringRef Opt(S);
- if (Opt.ends_with("="))
- Opt = Opt.drop_back(1);
+ Opt.consume_back("=");
if (Opt.starts_with("mno-"))
Opt = Opt.drop_front(4);
else if (Opt.starts_with("m"))
More information about the cfe-commits
mailing list