[PATCH] D136614: llvm-reduce: Report file opening errors
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 28 17:40:28 PDT 2022
arsenm updated this revision to Diff 471693.
arsenm edited the summary of this revision.
arsenm added a comment.
Consistently use ToolOutputFile and check error after close
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136614/new/
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
@@ -79,24 +79,17 @@
exit(1);
}
- 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";
- sys::fs::remove(CurrentFilepath);
- exit(1);
- }
- bool Res = Test.run(CurrentFilepath);
- sys::fs::remove(CurrentFilepath);
- return Res;
- }
ToolOutputFile Out(CurrentFilepath, FD);
- M.print(Out.os(), /*AnnotationWriter=*/nullptr);
+
+ if (TmpFilesAsBitcode)
+ writeBitcode(M, Out.os());
+ else
+ 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.471693.patch
Type: text/x-patch
Size: 1154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221029/9a791603/attachment.bin>
More information about the llvm-commits
mailing list