[llvm] 84ff1bd - [RISCV] Use StringRef in a range-based for loop (NFC) (#144243)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 14 23:23:53 PDT 2025


Author: Kazu Hirata
Date: 2025-06-14T23:23:49-07:00
New Revision: 84ff1bda2977e580265997ad2d4c47b18cd3bf9f

URL: https://github.com/llvm/llvm-project/commit/84ff1bda2977e580265997ad2d4c47b18cd3bf9f
DIFF: https://github.com/llvm/llvm-project/commit/84ff1bda2977e580265997ad2d4c47b18cd3bf9f.diff

LOG: [RISCV] Use StringRef in a range-based for loop (NFC) (#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.

Added: 
    

Modified: 
    llvm/lib/TargetParser/RISCVISAInfo.cpp

Removed: 
    


################################################################################
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