diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -73,7 +73,7 @@ void parse() const; DWARFAbbreviationDeclarationSetMap::const_iterator begin() const { - parse(); + assert(!Data && "Must call parse before iterating over DWARFDebugAbbrev"); return AbbrDeclSets.begin(); } diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -26,6 +26,7 @@ auto AbbrevSetPtr = DCtx.getDebugAbbrev(); if (AbbrevSetPtr) { uint64_t AbbrevTableID = 0; + AbbrevSetPtr->parse(); for (auto AbbrvDeclSet : *AbbrevSetPtr) { Y.DebugAbbrev.emplace_back(); Y.DebugAbbrev.back().ID = AbbrevTableID++; @@ -219,6 +220,7 @@ if (NewUnit.Version >= 5) NewUnit.Type = (dwarf::UnitType)CU->getUnitType(); const DWARFDebugAbbrev *DebugAbbrev = DCtx.getDebugAbbrev(); + DebugAbbrev->parse(); NewUnit.AbbrevTableID = std::distance( DebugAbbrev->begin(), llvm::find_if(