[llvm] r216348 - TableGen: use auto and for-range
Dylan Noblesmith
nobled at dreamwidth.org
Sun Aug 24 12:10:49 PDT 2014
Author: nobled
Date: Sun Aug 24 14:10:49 2014
New Revision: 216348
URL: http://llvm.org/viewvc/llvm-project?rev=216348&view=rev
Log:
TableGen: use auto and for-range
Modified:
llvm/trunk/lib/TableGen/Record.cpp
llvm/trunk/utils/TableGen/CTagsEmitter.cpp
llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=216348&r1=216347&r2=216348&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Sun Aug 24 14:10:49 2014
@@ -2014,16 +2014,14 @@ void RecordKeeper::dump() const { errs()
raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) {
OS << "------------- Classes -----------------\n";
- const std::map<std::string, Record*> &Classes = RK.getClasses();
- for (std::map<std::string, Record*>::const_iterator I = Classes.begin(),
- E = Classes.end(); I != E; ++I)
- OS << "class " << *I->second;
+ const auto &Classes = RK.getClasses();
+ for (const auto &C : Classes)
+ OS << "class " << *C.second;
OS << "------------- Defs -----------------\n";
- const std::map<std::string, Record*> &Defs = RK.getDefs();
- for (std::map<std::string, Record*>::const_iterator I = Defs.begin(),
- E = Defs.end(); I != E; ++I)
- OS << "def " << *I->second;
+ const auto &Defs = RK.getDefs();
+ for (const auto &D : Defs)
+ OS << "def " << *D.second;
return OS;
}
@@ -2038,10 +2036,9 @@ RecordKeeper::getAllDerivedDefinitions(c
PrintFatalError("ERROR: Couldn't find the `" + ClassName + "' class!\n");
std::vector<Record*> Defs;
- for (std::map<std::string, Record*>::const_iterator I = getDefs().begin(),
- E = getDefs().end(); I != E; ++I)
- if (I->second->isSubClassOf(Class))
- Defs.push_back(I->second);
+ for (const auto &D : getDefs())
+ if (D.second->isSubClassOf(Class))
+ Defs.push_back(D.second);
return Defs;
}
Modified: llvm/trunk/utils/TableGen/CTagsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CTagsEmitter.cpp?rev=216348&r1=216347&r2=216348&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CTagsEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/CTagsEmitter.cpp Sun Aug 24 14:10:49 2014
@@ -69,19 +69,15 @@ SMLoc CTagsEmitter::locate(const Record
}
void CTagsEmitter::run(raw_ostream &OS) {
- const std::map<std::string, Record *> &Classes = Records.getClasses();
- const std::map<std::string, Record *> &Defs = Records.getDefs();
+ const auto &Classes = Records.getClasses();
+ const auto &Defs = Records.getDefs();
std::vector<Tag> Tags;
// Collect tags.
Tags.reserve(Classes.size() + Defs.size());
- for (std::map<std::string, Record *>::const_iterator I = Classes.begin(),
- E = Classes.end();
- I != E; ++I)
- Tags.push_back(Tag(I->first, locate(I->second)));
- for (std::map<std::string, Record *>::const_iterator I = Defs.begin(),
- E = Defs.end();
- I != E; ++I)
- Tags.push_back(Tag(I->first, locate(I->second)));
+ for (const auto &C : Classes)
+ Tags.push_back(Tag(C.first, locate(C.second)));
+ for (const auto &D : Defs)
+ Tags.push_back(Tag(D.first, locate(D.second)));
// Emit tags.
std::sort(Tags.begin(), Tags.end());
OS << "!_TAG_FILE_FORMAT\t1\t/original ctags format/\n";
Modified: llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp?rev=216348&r1=216347&r2=216348&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp Sun Aug 24 14:10:49 2014
@@ -277,11 +277,10 @@ void PseudoLoweringEmitter::run(raw_ostr
assert(InstructionClass && "Instruction class definition missing!");
std::vector<Record*> Insts;
- for (std::map<std::string, Record*>::const_iterator I =
- Records.getDefs().begin(), E = Records.getDefs().end(); I != E; ++I) {
- if (I->second->isSubClassOf(ExpansionClass) &&
- I->second->isSubClassOf(InstructionClass))
- Insts.push_back(I->second);
+ for (const auto &D : Records.getDefs()) {
+ if (D.second->isSubClassOf(ExpansionClass) &&
+ D.second->isSubClassOf(InstructionClass))
+ Insts.push_back(D.second);
}
// Process the pseudo expansion definitions, validating them as we do so.
More information about the llvm-commits
mailing list