[llvm] eff6a21 - Attempt to pacify buildbots after 7d80b94ca3

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 17:08:36 PDT 2022


Author: Jessica Paquette
Date: 2022-09-12T17:08:08-07:00
New Revision: eff6a21dfb617bf1f70d81f4ed05fea282b48f5c

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

LOG: Attempt to pacify buildbots after 7d80b94ca3

Some compilers (like all the ones I've tried) seem to NVRO the
Expected<std::vector<unique_ptr>> 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.

Added: 
    

Modified: 
    llvm/tools/llvm-remarkutil/RemarkUtil.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-remarkutil/RemarkUtil.cpp b/llvm/tools/llvm-remarkutil/RemarkUtil.cpp
index 5cb641a0ba01..cc6edc7f2b6c 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<std::vector<std::unique_ptr<Remark>>>
-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<std::unique_ptr<Remark>> &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<std::unique_ptr<Remark>> ParsedRemarks;
   for (; MaybeRemark; MaybeRemark = Parser.next()) {
     StrTab.internalize(**MaybeRemark);
     ParsedRemarks.push_back(std::move(*MaybeRemark));
   }
   auto E = MaybeRemark.takeError();
   if (!E.isA<EndOfFileError>())
-    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<std::unique_ptr<Remark>> ParsedRemarks;
+  ExitOnErr(tryParseRemarksFromInputFile(InputFileName, InputFormat,
+                                         ParsedRemarks, StrTab));
   return tryReserializeParsedRemarks(OutputFileName, OutputFormat,
-                                     *MaybeParsedRemarks, StrTab);
+                                     ParsedRemarks, StrTab);
 }
 
 /// Reserialize bitstream remarks as YAML remarks.


        


More information about the llvm-commits mailing list