[PATCH] D58130: [llvm-dwp] Avoid writing the output dwp file when there is an error

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 12 12:01:12 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL353873: [llvm-dwp] Avoid writing the output dwp file when there is an error (authored by rupprecht, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58130?vs=186482&id=186527#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58130/new/

https://reviews.llvm.org/D58130

Files:
  llvm/trunk/test/tools/llvm-dwp/X86/missing_dwo_id.test
  llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp


Index: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
===================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -700,23 +701,23 @@
 
   // Create the output file.
   std::error_code EC;
-  raw_fd_ostream OutFile(OutputFilename, EC, sys::fs::F_None);
+  ToolOutputFile OutFile(OutputFilename, EC, sys::fs::F_None);
   Optional<buffer_ostream> BOS;
   raw_pwrite_stream *OS;
   if (EC)
     return error(Twine(OutputFilename) + ": " + EC.message(), Context);
-  if (OutFile.supportsSeeking()) {
-    OS = &OutFile;
+  if (OutFile.os().supportsSeeking()) {
+    OS = &OutFile.os();
   } else {
-    BOS.emplace(OutFile);
+    BOS.emplace(OutFile.os());
     OS = BOS.getPointer();
   }
 
   MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
   std::unique_ptr<MCStreamer> MS(TheTarget->createMCObjectStreamer(
       TheTriple, MC, std::unique_ptr<MCAsmBackend>(MAB),
-      MAB->createObjectWriter(*OS), std::unique_ptr<MCCodeEmitter>(MCE),
-      *MSTI, MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
+      MAB->createObjectWriter(*OS), std::unique_ptr<MCCodeEmitter>(MCE), *MSTI,
+      MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
       /*DWARFMustBeAtTheEnd*/ false));
   if (!MS)
     return error("no object streamer for target " + TripleName, Context);
@@ -739,4 +740,6 @@
   }
 
   MS->Finish();
+  OutFile.keep();
+  return 0;
 }
Index: llvm/trunk/test/tools/llvm-dwp/X86/missing_dwo_id.test
===================================================================
--- llvm/trunk/test/tools/llvm-dwp/X86/missing_dwo_id.test
+++ llvm/trunk/test/tools/llvm-dwp/X86/missing_dwo_id.test
@@ -1,3 +1,7 @@
+RUN: rm -f %t
 RUN: not llvm-dwp %p/../Inputs/missing_dwo_id.dwo -o %t 2>&1 | FileCheck %s
 
+Make sure we did not leave behind a temporary file:
+RUN: not ls %t
+
 CHECK: error: {{.*}}missing_dwo_id.dwo': compile unit missing dwo_id


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58130.186527.patch
Type: text/x-patch
Size: 2211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190212/cebf2d3c/attachment.bin>


More information about the llvm-commits mailing list