basic_block: Use a range-based for loop for iteration

This commit is contained in:
Lioncash 2016-08-23 12:35:57 -04:00 committed by MerryMage
parent 897b776250
commit 2180a4be7a

View file

@ -57,8 +57,8 @@ std::string DumpBlock(const IR::Block& block) {
} }
}; };
for (auto inst = block.begin(); inst != block.end(); ++inst) { for (const auto& inst : block) {
const Opcode op = inst->GetOpcode(); const Opcode op = inst.GetOpcode();
if (GetTypeOf(op) != Type::Void) { if (GetTypeOf(op) != Type::Void) {
ret += Common::StringFromFormat("%%%-5zu = ", index); ret += Common::StringFromFormat("%%%-5zu = ", index);
@ -70,7 +70,7 @@ std::string DumpBlock(const IR::Block& block) {
const size_t arg_count = GetNumArgsOf(op); const size_t arg_count = GetNumArgsOf(op);
for (size_t arg_index = 0; arg_index < arg_count; arg_index++) { for (size_t arg_index = 0; arg_index < arg_count; arg_index++) {
const Value arg = inst->GetArg(arg_index); const Value arg = inst.GetArg(arg_index);
ret += arg_index != 0 ? ", " : " "; ret += arg_index != 0 ? ", " : " ";
ret += arg_to_string(arg); ret += arg_to_string(arg);
@ -83,7 +83,7 @@ std::string DumpBlock(const IR::Block& block) {
} }
ret += "\n"; ret += "\n";
inst_to_index[&*inst] = index++; inst_to_index[&inst] = index++;
} }
return ret; return ret;