From 44bc71549e15587f38635e48b2b95b6f4b216d4c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 4 Jun 2015 07:40:14 +0000 Subject: [PATCH] [TableGen] Use range-based for loops. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239022 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/Record.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index a0b48ff5402..6170a37e4ca 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -1646,9 +1646,11 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) { const std::vector &TArgs = R.getTemplateArgs(); if (!TArgs.empty()) { OS << "<"; - for (unsigned i = 0, e = TArgs.size(); i != e; ++i) { - if (i) OS << ", "; - const RecordVal *RV = R.getValue(TArgs[i]); + bool NeedComma = false; + for (const Init *TA : TArgs) { + if (NeedComma) OS << ", "; + NeedComma = true; + const RecordVal *RV = R.getValue(TA); assert(RV && "Template argument record not found??"); RV->print(OS, false); } @@ -1659,18 +1661,17 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) { const std::vector &SC = R.getSuperClasses(); if (!SC.empty()) { OS << "\t//"; - for (unsigned i = 0, e = SC.size(); i != e; ++i) - OS << " " << SC[i]->getNameInitAsString(); + for (const Record *Super : SC) + OS << " " << Super->getNameInitAsString(); } OS << "\n"; - const std::vector &Vals = R.getValues(); - for (unsigned i = 0, e = Vals.size(); i != e; ++i) - if (Vals[i].getPrefix() && !R.isTemplateArg(Vals[i].getName())) - OS << Vals[i]; - for (unsigned i = 0, e = Vals.size(); i != e; ++i) - if (!Vals[i].getPrefix() && !R.isTemplateArg(Vals[i].getName())) - OS << Vals[i]; + for (const RecordVal &Val : R.getValues()) + if (Val.getPrefix() && !R.isTemplateArg(Val.getName())) + OS << Val; + for (const RecordVal &Val : R.getValues()) + if (!Val.getPrefix() && !R.isTemplateArg(Val.getName())) + OS << Val; return OS << "}\n"; } -- 2.34.1