diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-06-02 04:15:51 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-06-02 04:15:51 +0000 |
commit | ef0578a8cb14afbd80e29f7e8ebd0840765b822c (patch) | |
tree | eb034245733a924c4e13f5fcba97afc537a89a8a /llvm/lib/TableGen | |
parent | 2e9df17aa7a38b674e8a21531d31b72c21b8be66 (diff) | |
download | bcm5719-llvm-ef0578a8cb14afbd80e29f7e8ebd0840765b822c.tar.gz bcm5719-llvm-ef0578a8cb14afbd80e29f7e8ebd0840765b822c.zip |
[TableGen] Use range-based for loops. NFC.
llvm-svn: 238805
Diffstat (limited to 'llvm/lib/TableGen')
-rw-r--r-- | llvm/lib/TableGen/Record.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 3097c4ee33e..02c54aaec93 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -504,8 +504,8 @@ Init *ListInit::convertInitializerTo(RecTy *Ty) const { // Verify that all of the elements of the list are subclasses of the // appropriate class! - for (unsigned i = 0, e = getSize(); i != e; ++i) - if (Init *CI = getElement(i)->convertInitializerTo(LRT->getElementType())) + for (Init *I : getValues()) + if (Init *CI = I->convertInitializerTo(LRT->getElementType())) Elements.push_back(CI); else return nullptr; @@ -541,9 +541,8 @@ Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) const { Resolved.reserve(getSize()); bool Changed = false; - for (unsigned i = 0, e = getSize(); i != e; ++i) { + for (Init *CurElt : getValues()) { Init *E; - Init *CurElt = getElement(i); do { E = CurElt; @@ -1744,8 +1743,8 @@ std::vector<Record*> Record::getValueAsListOfDefs(StringRef FieldName) const { ListInit *List = getValueAsListInit(FieldName); std::vector<Record*> Defs; - for (unsigned i = 0; i < List->getSize(); i++) { - if (DefInit *DI = dyn_cast<DefInit>(List->getElement(i))) + for (Init *I : List->getValues()) { + if (DefInit *DI = dyn_cast<DefInit>(I)) Defs.push_back(DI->getDef()); else PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + @@ -1778,8 +1777,8 @@ std::vector<int64_t> Record::getValueAsListOfInts(StringRef FieldName) const { ListInit *List = getValueAsListInit(FieldName); std::vector<int64_t> Ints; - for (unsigned i = 0; i < List->getSize(); i++) { - if (IntInit *II = dyn_cast<IntInit>(List->getElement(i))) + for (Init *I : List->getValues()) { + if (IntInit *II = dyn_cast<IntInit>(I)) Ints.push_back(II->getValue()); else PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + @@ -1796,9 +1795,9 @@ std::vector<std::string> Record::getValueAsListOfStrings(StringRef FieldName) const { ListInit *List = getValueAsListInit(FieldName); std::vector<std::string> Strings; - for (unsigned i = 0; i < List->getSize(); i++) { - if (StringInit *II = dyn_cast<StringInit>(List->getElement(i))) - Strings.push_back(II->getValue()); + for (Init *I : List->getValues()) { + if (StringInit *SI = dyn_cast<StringInit>(I)) + Strings.push_back(SI->getValue()); else PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + FieldName + "' does not have a list of strings initializer!"); |