[PATCH] D136614: llvm-reduce: Report file opening errors

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 09:19:01 PDT 2022


arsenm created this revision.
arsenm added reviewers: regehr, aeubanks, lebedev.ri.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

This was also trying to write the bitcode to the failed file
 on failure, which asserts.


https://reviews.llvm.org/D136614

Files:
  llvm/tools/llvm-reduce/deltas/Delta.cpp


Index: llvm/tools/llvm-reduce/deltas/Delta.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -81,13 +81,17 @@
 
   if (TmpFilesAsBitcode) {
     llvm::raw_fd_ostream OutStream(FD, true);
-    writeBitcode(M, OutStream);
-    OutStream.close();
+
     if (OutStream.has_error()) {
-      errs() << "Error emitting bitcode to file '" << CurrentFilepath << "'!\n";
+      errs() << "Error emitting bitcode to file '" << CurrentFilepath
+             << "': " << OutStream.error().message();
       sys::fs::remove(CurrentFilepath);
       exit(1);
     }
+
+    writeBitcode(M, OutStream);
+    OutStream.close();
+
     bool Res = Test.run(CurrentFilepath);
     sys::fs::remove(CurrentFilepath);
     return Res;
@@ -96,7 +100,8 @@
   M.print(Out.os(), /*AnnotationWriter=*/nullptr);
   Out.os().close();
   if (Out.os().has_error()) {
-    errs() << "Error emitting bitcode to file '" << CurrentFilepath << "'!\n";
+    errs() << "Error emitting bitcode to file '" << CurrentFilepath
+           << "': " << Out.os().error().message();
     exit(1);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136614.470183.patch
Type: text/x-patch
Size: 1170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221024/add15b53/attachment.bin>


More information about the llvm-commits mailing list