summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader-opcnt.cc12
-rw-r--r--src/c-writer.cc5
-rw-r--r--src/ir.cc7
-rw-r--r--src/tools/wasm-opcodecnt.cc17
-rw-r--r--src/wast-parser.cc4
5 files changed, 19 insertions, 26 deletions
diff --git a/src/binary-reader-opcnt.cc b/src/binary-reader-opcnt.cc
index c01eca6a..94ba1b08 100644
--- a/src/binary-reader-opcnt.cc
+++ b/src/binary-reader-opcnt.cc
@@ -61,19 +61,19 @@ std::pair<const T*, size_t> OpcodeInfo::GetDataArray() const {
template <typename T>
const T* OpcodeInfo::GetData(size_t expected_size) const {
- auto pair = GetDataArray<T>();
- assert(pair.second == expected_size);
- return pair.first;
+ auto [data, size] = GetDataArray<T>();
+ assert(size == expected_size);
+ return data;
}
template <typename T, typename F>
void OpcodeInfo::WriteArray(Stream& stream, F&& write_func) {
- auto pair = GetDataArray<T>();
- for (size_t i = 0; i < pair.second; ++i) {
+ auto [data, size] = GetDataArray<T>();
+ for (size_t i = 0; i < size; ++i) {
// Write an initial space (to separate from the opcode name) first, then
// comma-separate.
stream.Writef("%s", i == 0 ? " " : ", ");
- write_func(pair.first[i]);
+ write_func(data[i]);
}
}
diff --git a/src/c-writer.cc b/src/c-writer.cc
index 473f0199..635334dd 100644
--- a/src/c-writer.cc
+++ b/src/c-writer.cc
@@ -1346,9 +1346,8 @@ void CWriter::WriteLocals(const std::vector<std::string>& index_to_name) {
void CWriter::WriteStackVarDeclarations() {
for (Type type : {Type::I32, Type::I64, Type::F32, Type::F64}) {
size_t count = 0;
- for (const auto& pair : stack_var_sym_map_) {
- Type stp_type = pair.first.second;
- const std::string& name = pair.second;
+ for (const auto& [pair, name] : stack_var_sym_map_) {
+ Type stp_type = pair.second;
if (stp_type == type) {
if (count == 0) {
diff --git a/src/ir.cc b/src/ir.cc
index 3af95685..96629751 100644
--- a/src/ir.cc
+++ b/src/ir.cc
@@ -574,10 +574,9 @@ void MakeTypeBindingReverseMapping(
std::vector<std::string>* out_reverse_mapping) {
out_reverse_mapping->clear();
out_reverse_mapping->resize(num_types);
- for (const auto& pair : bindings) {
- assert(static_cast<size_t>(pair.second.index) <
- out_reverse_mapping->size());
- (*out_reverse_mapping)[pair.second.index] = pair.first;
+ for (const auto& [name, binding] : bindings) {
+ assert(static_cast<size_t>(binding.index) < out_reverse_mapping->size());
+ (*out_reverse_mapping)[binding.index] = name;
}
}
diff --git a/src/tools/wasm-opcodecnt.cc b/src/tools/wasm-opcodecnt.cc
index 4df8598b..648a2636 100644
--- a/src/tools/wasm-opcodecnt.cc
+++ b/src/tools/wasm-opcodecnt.cc
@@ -90,8 +90,8 @@ struct WithinCutoff {
static size_t SumCounts(const OpcodeInfoCounts& info_counts) {
size_t sum = 0;
- for (auto& pair : info_counts) {
- sum += pair.second;
+ for (auto& [info, count] : info_counts) {
+ sum += count;
}
return sum;
}
@@ -100,9 +100,8 @@ void WriteCounts(Stream& stream, const OpcodeInfoCounts& info_counts) {
typedef std::pair<Opcode, size_t> OpcodeCountPair;
std::map<Opcode, size_t> counts;
- for (auto& info_count_pair : info_counts) {
- Opcode opcode = info_count_pair.first.opcode();
- size_t count = info_count_pair.second;
+ for (auto& [info, count] : info_counts) {
+ Opcode opcode = info.opcode();
counts[opcode] += count;
}
@@ -115,9 +114,7 @@ void WriteCounts(Stream& stream, const OpcodeInfoCounts& info_counts) {
std::stable_sort(sorted.begin(), sorted.end(),
SortByCountDescending<OpcodeCountPair>());
- for (auto& pair : sorted) {
- Opcode opcode = pair.first;
- size_t count = pair.second;
+ for (auto& [opcode, count] : sorted) {
stream.Writef("%s%s%" PRIzd "\n", opcode.GetName(), s_separator, count);
}
}
@@ -137,9 +134,7 @@ void WriteCountsWithImmediates(Stream& stream, const OpcodeInfoCounts& counts) {
std::stable_sort(sorted.begin(), sorted.end(),
SortByCountDescending<OpcodeInfoCountPair>());
- for (auto& pair : sorted) {
- auto&& info = pair.first;
- size_t count = pair.second;
+ for (auto& [info, count] : sorted) {
info.Write(stream);
stream.Writef("%s%" PRIzd "\n", s_separator, count);
}
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index 96e7d336..8264522b 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -496,8 +496,8 @@ Result ResolveFuncTypes(Module* module, Errors* errors) {
// local variables share the same index space, we need to increment the
// local indexes bound to a given name by the number of parameters in
// the function.
- for (auto& pair : func->bindings) {
- pair.second.index += func->GetNumParams();
+ for (auto& [name, binding] : func->bindings) {
+ binding.index += func->GetNumParams();
}
}