diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -412,10 +412,10 @@ return std::make_pair(std::move(Stream), Headers); } -static std::vector getSectionNames(PDBFile &File) { +static Expected> getSectionNames(PDBFile &File) { auto ExpectedHeaders = loadSectionHeaders(File, DbgHeaderType::SectionHdr); if (!ExpectedHeaders) - return {}; + return ExpectedHeaders.takeError(); std::unique_ptr Stream; ArrayRef Headers; @@ -485,7 +485,10 @@ [&](uint32_t Modi, const SymbolGroup &Strings) -> Error { auto Desc = Modules.getModuleDescriptor(Modi); if (opts::dump::DumpSectionContribs) { - std::vector Sections = getSectionNames(getPdb()); + auto SectionsOrErr = getSectionNames(getPdb()); + if (!SectionsOrErr) + return SectionsOrErr.takeError(); + ArrayRef Sections = *SectionsOrErr; dumpSectionContrib(P, Desc.getSectionContrib(), Sections, 0); } P.formatLine("Obj: `{0}`: ", Desc.getObjFileName()); @@ -1840,8 +1843,11 @@ ArrayRef Names; }; - std::vector Names = getSectionNames(getPdb()); - Visitor V(P, makeArrayRef(Names)); + auto NamesOrErr = getSectionNames(getPdb()); + if (!NamesOrErr) + return NamesOrErr.takeError(); + ArrayRef Names = *NamesOrErr; + Visitor V(P, Names); Dbi.visitSectionContributions(V); return Error::success(); }