[llvm] 7848bf1 - [ObjectYAML] WasmWriter::writeSectionContent - use llvm::enumerate to fix 'side effect in assert' warning

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 2 08:09:28 PST 2022


Author: Simon Pilgrim
Date: 2022-03-02T16:09:09Z
New Revision: 7848bf16fe7553cc65745240ae01ebf2949c323b

URL: https://github.com/llvm/llvm-project/commit/7848bf16fe7553cc65745240ae01ebf2949c323b
DIFF: https://github.com/llvm/llvm-project/commit/7848bf16fe7553cc65745240ae01ebf2949c323b.diff

LOG: [ObjectYAML] WasmWriter::writeSectionContent - use llvm::enumerate to fix 'side effect in assert' warning

Added: 
    

Modified: 
    llvm/lib/ObjectYAML/WasmEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ObjectYAML/WasmEmitter.cpp b/llvm/lib/ObjectYAML/WasmEmitter.cpp
index 2aa2ef3e55417..401bc92207f9c 100644
--- a/llvm/lib/ObjectYAML/WasmEmitter.cpp
+++ b/llvm/lib/ObjectYAML/WasmEmitter.cpp
@@ -187,13 +187,10 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
   // SYMBOL_TABLE subsection
   if (Section.SymbolTable.size()) {
     writeUint8(OS, wasm::WASM_SYMBOL_TABLE);
-
     encodeULEB128(Section.SymbolTable.size(), SubSection.getStream());
-#ifndef NDEBUG
-    uint32_t SymbolIndex = 0;
-#endif
-    for (const WasmYAML::SymbolInfo &Info : Section.SymbolTable) {
-      assert(Info.Index == SymbolIndex++);
+    for (auto Sym : llvm::enumerate(Section.SymbolTable)) {
+      const WasmYAML::SymbolInfo &Info = Sym.value();
+      assert(Info.Index == Sym.index());
       writeUint8(SubSection.getStream(), Info.Kind);
       encodeULEB128(Info.Flags, SubSection.getStream());
       switch (Info.Kind) {


        


More information about the llvm-commits mailing list