[llvm] [TableGen] Use range-based for loops (NFC) (PR #97678)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 22:29:14 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97678
None
>From cee190f3cebd35f0365714b381fc037207689a74 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 2 Jul 2024 17:29:38 -0700
Subject: [PATCH] [TableGen] Use range-based for loops (NFC)
---
llvm/lib/TableGen/Record.cpp | 6 +++---
llvm/lib/TableGen/TGParser.cpp | 5 ++---
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index f9acc68ce5c7fd..d5e7af275d792d 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -2283,9 +2283,9 @@ DefInit *VarDefInit::instantiate() {
ArrayRef<Init *> TArgs = Class->getTemplateArgs();
MapResolver R(NewRec);
- for (unsigned I = 0, E = TArgs.size(); I != E; ++I) {
- R.set(TArgs[I], NewRec->getValue(TArgs[I])->getValue());
- NewRec->removeValue(TArgs[I]);
+ for (Init *Arg : TArgs) {
+ R.set(Arg, NewRec->getValue(Arg)->getValue());
+ NewRec->removeValue(Arg);
}
for (auto *Arg : args()) {
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index f899fdb68f7582..ce9da960545c23 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -4381,8 +4381,7 @@ bool TGParser::CheckTemplateArgValues(
SmallVectorImpl<llvm::ArgumentInit *> &Values, SMLoc Loc, Record *ArgsRec) {
ArrayRef<Init *> TArgs = ArgsRec->getTemplateArgs();
- for (unsigned I = 0, E = Values.size(); I < E; ++I) {
- auto *Value = Values[I];
+ for (llvm::ArgumentInit *&Value : Values) {
Init *ArgName = nullptr;
if (Value->isPositional())
ArgName = TArgs[Value->getIndex()];
@@ -4398,7 +4397,7 @@ bool TGParser::CheckTemplateArgValues(
assert((!isa<TypedInit>(CastValue) ||
cast<TypedInit>(CastValue)->getType()->typeIsA(ArgType)) &&
"result of template arg value cast has wrong type");
- Values[I] = Value->cloneWithValue(CastValue);
+ Value = Value->cloneWithValue(CastValue);
} else {
PrintFatalError(Loc, "Value specified for template argument '" +
Arg->getNameInitAsString() + "' is of type " +
More information about the llvm-commits
mailing list