[llvm] [RISCV] Use StringRef in a range-based for loop (NFC) (PR #144243)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 14 17:38:51 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/144243
When we iterate over std::vector<std::string>, we can directly assign
each element to StringRef. We do not need to go through a separate
statement.
>From 832995c0d9816a06a39a15c9f90065d3c74528d5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 13 Jun 2025 13:30:47 -0700
Subject: [PATCH] [RISCV] Use StringRef in a range-based for loop (NFC)
When we iterate over std::vector<std::string>, we can directly assign
each element to StringRef. We do not need to go through a separate
statement.
---
llvm/lib/TargetParser/RISCVISAInfo.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index e76ddd4b648dc..17c98332ab0af 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -449,8 +449,7 @@ RISCVISAInfo::parseFeatures(unsigned XLen,
assert(XLen == 32 || XLen == 64);
std::unique_ptr<RISCVISAInfo> ISAInfo(new RISCVISAInfo(XLen));
- for (auto &Feature : Features) {
- StringRef ExtName = Feature;
+ for (StringRef ExtName : Features) {
assert(ExtName.size() > 1 && (ExtName[0] == '+' || ExtName[0] == '-'));
bool Add = ExtName[0] == '+';
ExtName = ExtName.drop_front(1); // Drop '+' or '-'
More information about the llvm-commits
mailing list