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 @@ -531,10 +531,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; @@ -604,8 +604,10 @@ [&](uint32_t Modi, const SymbolGroup &Strings) -> Error { auto Desc = Modules.getModuleDescriptor(Modi); if (opts::dump::DumpSectionContribs) { - std::vector Sections = getSectionNames(getPdb()); - dumpSectionContrib(P, Desc.getSectionContrib(), Sections, 0); + auto Sections = getSectionNames(getPdb()); + if (!Sections) + return Sections.takeError(); + dumpSectionContrib(P, Desc.getSectionContrib(), *Sections, 0); } P.formatLine("Obj: `{0}`: ", Desc.getObjFileName()); P.formatLine("debug stream: {0}, # files: {1}, has ec info: {2}", @@ -1959,8 +1961,10 @@ ArrayRef Names; }; - std::vector Names = getSectionNames(getPdb()); - Visitor V(P, makeArrayRef(Names)); + auto Names = getSectionNames(getPdb()); + if (!Names) + return Names.takeError(); + Visitor V(P, makeArrayRef(*Names)); Dbi.visitSectionContributions(V); return Error::success(); }