From eff6a21dfb617bf1f70d81f4ed05fea282b48f5c Mon Sep 17 00:00:00 2001 From: Jessica Paquette Date: Mon, 12 Sep 2022 16:50:15 -0700 Subject: [PATCH] Attempt to pacify buildbots after 7d80b94ca3 Some compilers (like all the ones I've tried) seem to NVRO the Expected> but other ones (like some of the bots) seem to not want to. Change the return type to Error and pass in the vector as an output parameter to try and fix things. --- llvm/tools/llvm-remarkutil/RemarkUtil.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/llvm/tools/llvm-remarkutil/RemarkUtil.cpp b/llvm/tools/llvm-remarkutil/RemarkUtil.cpp index 5cb641a..cc6edc7 100644 --- a/llvm/tools/llvm-remarkutil/RemarkUtil.cpp +++ b/llvm/tools/llvm-remarkutil/RemarkUtil.cpp @@ -76,11 +76,13 @@ getInputMemoryBuffer(StringRef InputFileName) { } /// Parses all remarks in the input file. +/// \p [out] ParsedRemarks - Filled with remarks parsed from the input file. /// \p [out] StrTab - A string table populated for later remark serialization. -/// \returns A vector of parsed remarks on success, and an Error otherwise. -static Expected>> -tryParseRemarksFromInputFile(StringRef InputFileName, Format InputFormat, - StringTable &StrTab) { +/// \returns Error::success() if all remarks were successfully parsed, and an +/// Error otherwise. +Error tryParseRemarksFromInputFile( + StringRef InputFileName, Format InputFormat, + std::vector> &ParsedRemarks, StringTable &StrTab) { auto MaybeBuf = getInputMemoryBuffer(InputFileName); if (!MaybeBuf) return MaybeBuf.takeError(); @@ -91,16 +93,15 @@ tryParseRemarksFromInputFile(StringRef InputFileName, Format InputFormat, auto MaybeRemark = Parser.next(); // TODO: If we are converting from bitstream to YAML, we don't need to parse // early because the string table is not necessary. - std::vector> ParsedRemarks; for (; MaybeRemark; MaybeRemark = Parser.next()) { StrTab.internalize(**MaybeRemark); ParsedRemarks.push_back(std::move(*MaybeRemark)); } auto E = MaybeRemark.takeError(); if (!E.isA()) - return std::move(E); + return E; consumeError(std::move(E)); - return ParsedRemarks; + return Error::success(); } /// \returns A ToolOutputFile which can be used for writing remarks on success, @@ -148,12 +149,11 @@ static Error tryReserializeParsedRemarks( static Error tryReserialize(StringRef InputFileName, StringRef OutputFileName, Format InputFormat, Format OutputFormat) { StringTable StrTab; - auto MaybeParsedRemarks = - tryParseRemarksFromInputFile(InputFileName, InputFormat, StrTab); - if (!MaybeParsedRemarks) - return MaybeParsedRemarks.takeError(); + std::vector> ParsedRemarks; + ExitOnErr(tryParseRemarksFromInputFile(InputFileName, InputFormat, + ParsedRemarks, StrTab)); return tryReserializeParsedRemarks(OutputFileName, OutputFormat, - *MaybeParsedRemarks, StrTab); + ParsedRemarks, StrTab); } /// Reserialize bitstream remarks as YAML remarks. -- 2.7.4