[llvm] [RISCV] Use StringRef in a range-based for loop (NFC) (PR #144243)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 14 17:39:17 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/144243.diff
1 Files Affected:
- (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+1-2)
``````````diff
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 '-'
``````````
</details>
https://github.com/llvm/llvm-project/pull/144243
More information about the llvm-commits
mailing list