diff options
author | Alon Zakai <azakai@google.com> | 2023-04-25 12:00:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 12:00:59 -0700 |
commit | f7706ad4999a087140924f073e1a2135d4ea9074 (patch) | |
tree | 6b7ae89a2570664b614fa821552e25b79a817a87 /src | |
parent | a83a8361fec78822bd23ef4d6764199a78c2c649 (diff) | |
download | binaryen-f7706ad4999a087140924f073e1a2135d4ea9074.tar.gz binaryen-f7706ad4999a087140924f073e1a2135d4ea9074.tar.bz2 binaryen-f7706ad4999a087140924f073e1a2135d4ea9074.zip |
[NFC] Assert that module maps are the right size (#5687)
If the names are not unique then the map would be smaller than
the vector it is built from.
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 47a04d7f8..f3e345895 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1591,6 +1591,7 @@ void Module::updateFunctionsMap() { for (auto& curr : functions) { functionsMap[curr->name] = curr.get(); } + assert(functionsMap.size() == functions.size()); } void Module::updateDataSegmentsMap() { @@ -1598,6 +1599,7 @@ void Module::updateDataSegmentsMap() { for (auto& curr : dataSegments) { dataSegmentsMap[curr->name] = curr.get(); } + assert(dataSegmentsMap.size() == dataSegments.size()); } void Module::updateMaps() { @@ -1606,27 +1608,33 @@ void Module::updateMaps() { for (auto& curr : exports) { exportsMap[curr->name] = curr.get(); } + assert(exportsMap.size() == exports.size()); tablesMap.clear(); for (auto& curr : tables) { tablesMap[curr->name] = curr.get(); } + assert(tablesMap.size() == tables.size()); elementSegmentsMap.clear(); for (auto& curr : elementSegments) { elementSegmentsMap[curr->name] = curr.get(); } + assert(elementSegmentsMap.size() == elementSegments.size()); memoriesMap.clear(); for (auto& curr : memories) { memoriesMap[curr->name] = curr.get(); } + assert(memoriesMap.size() == memories.size()); updateDataSegmentsMap(); globalsMap.clear(); for (auto& curr : globals) { globalsMap[curr->name] = curr.get(); } + assert(globalsMap.size() == globals.size()); tagsMap.clear(); for (auto& curr : tags) { tagsMap[curr->name] = curr.get(); } + assert(tagsMap.size() == tags.size()); } void Module::clearDebugInfo() { debugInfoFileNames.clear(); } |