[PATCH] D93526: [TableGen] NFC: Switch to range-based for loops in OptParserEmitter
Jan Svoboda via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 21 02:59:22 PST 2020
jansvoboda11 updated this revision to Diff 313059.
jansvoboda11 added a comment.
Incorporate review feedback
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93526/new/
https://reviews.llvm.org/D93526
Files:
llvm/utils/TableGen/OptParserEmitter.cpp
Index: llvm/utils/TableGen/OptParserEmitter.cpp
===================================================================
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -219,8 +219,7 @@
PrefixesT Prefixes;
Prefixes.insert(std::make_pair(PrefixKeyT(), "prefix_0"));
unsigned CurPrefix = 0;
- for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
- const Record &R = *Opts[i];
+ for (const Record &R : llvm::make_pointee_range(Opts)) {
std::vector<StringRef> prf = R.getValueAsListOfStrings("Prefixes");
PrefixKeyT prfkey(prf.begin(), prf.end());
unsigned NewPrefix = CurPrefix + 1;
@@ -235,19 +234,16 @@
OS << "// Prefixes\n\n";
OS << "#ifdef PREFIX\n";
OS << "#define COMMA ,\n";
- for (PrefixesT::const_iterator I = Prefixes.begin(), E = Prefixes.end();
- I != E; ++I) {
+ for (const auto &Prefix : Prefixes) {
OS << "PREFIX(";
// Prefix name.
- OS << I->second;
+ OS << Prefix.second;
// Prefix values.
OS << ", {";
- for (PrefixKeyT::const_iterator PI = I->first.begin(),
- PE = I->first.end(); PI != PE; ++PI) {
- OS << "\"" << *PI << "\" COMMA ";
- }
+ for (StringRef PrefixKey : Prefix.first)
+ OS << "\"" << PrefixKey << "\" COMMA ";
OS << "nullptr})\n";
}
OS << "#undef COMMA\n";
@@ -256,9 +252,7 @@
OS << "/////////\n";
OS << "// Groups\n\n";
OS << "#ifdef OPTION\n";
- for (unsigned i = 0, e = Groups.size(); i != e; ++i) {
- const Record &R = *Groups[i];
-
+ for (const Record &R : llvm::make_pointee_range(Groups)) {
// Start a single option entry.
OS << "OPTION(";
@@ -343,8 +337,8 @@
OS << "nullptr";
} else {
OS << "\"";
- for (size_t i = 0, e = AliasArgs.size(); i != e; ++i)
- OS << AliasArgs[i] << "\\0";
+ for (StringRef AliasArg : AliasArgs)
+ OS << AliasArg << "\\0";
OS << "\"";
}
@@ -394,9 +388,7 @@
};
std::vector<const Record *> OptsWithMarshalling;
- for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
- const Record &R = *Opts[I];
-
+ for (const Record &R : llvm::make_pointee_range(Opts)) {
// Start a single option entry.
OS << "OPTION(";
WriteOptRecordFields(OS, R);
@@ -462,8 +454,7 @@
OS << "#ifdef OPTTABLE_ARG_INIT\n";
OS << "//////////\n";
OS << "// Option Values\n\n";
- for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
- const Record &R = *Opts[I];
+ for (const Record &R : llvm::make_pointee_range(Opts)) {
if (isa<UnsetInit>(R.getValueInit("ValuesCode")))
continue;
OS << "{\n";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93526.313059.patch
Type: text/x-patch
Size: 2673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201221/df3850db/attachment.bin>
More information about the llvm-commits
mailing list