[llvm-commits] [llvm] r111604 - in /llvm/trunk/tools: llvm-extract/llvm-extract.cpp llvm-link/llvm-link.cpp

Dan Gohman gohman at apple.com
Thu Aug 19 18:12:13 PDT 2010


Author: djg
Date: Thu Aug 19 20:12:13 2010
New Revision: 111604

URL: http://llvm.org/viewvc/llvm-project?rev=111604&view=rev
Log:
Use tool_output_file in llvm-extract and llvm-link too.

Modified:
    llvm/trunk/tools/llvm-extract/llvm-extract.cpp
    llvm/trunk/tools/llvm-link/llvm-link.cpp

Modified: llvm/trunk/tools/llvm-extract/llvm-extract.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=111604&r1=111603&r2=111604&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-extract/llvm-extract.cpp (original)
+++ llvm/trunk/tools/llvm-extract/llvm-extract.cpp Thu Aug 19 20:12:13 2010
@@ -116,14 +116,9 @@
   Passes.add(createDeadTypeEliminationPass());   // Remove dead types...
   Passes.add(createStripDeadPrototypesPass());   // Remove dead func decls
 
-  // Make sure that the Output file gets unlinked from the disk if we get a
-  // SIGINT
-  if (OutputFilename != "-")
-    sys::RemoveFileOnSignal(sys::Path(OutputFilename));
-
   std::string ErrorInfo;
-  raw_fd_ostream Out(OutputFilename.c_str(), ErrorInfo,
-                     raw_fd_ostream::F_Binary);
+  tool_output_file Out(OutputFilename.c_str(), ErrorInfo,
+                       raw_fd_ostream::F_Binary);
   if (!ErrorInfo.empty()) {
     errs() << ErrorInfo << '\n';
     return 1;
@@ -136,5 +131,8 @@
 
   Passes.run(*M.get());
 
+  // Declare success.
+  Out.keep();
+
   return 0;
 }

Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=111604&r1=111603&r2=111604&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)
+++ llvm/trunk/tools/llvm-link/llvm-link.cpp Thu Aug 19 20:12:13 2010
@@ -116,19 +116,13 @@
   if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite;
 
   std::string ErrorInfo;
-  std::auto_ptr<raw_ostream> 
-  Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
-                         raw_fd_ostream::F_Binary));
+  tool_output_file Out(OutputFilename.c_str(), ErrorInfo,
+                       raw_fd_ostream::F_Binary);
   if (!ErrorInfo.empty()) {
     errs() << ErrorInfo << '\n';
     return 1;
   }
 
-    // Make sure that the Out file gets unlinked from the disk if we get a
-    // SIGINT
-  if (OutputFilename != "-")
-    sys::RemoveFileOnSignal(sys::Path(OutputFilename));
-
   if (verifyModule(*Composite)) {
     errs() << argv[0] << ": linked module is broken!\n";
     return 1;
@@ -136,9 +130,12 @@
 
   if (Verbose) errs() << "Writing bitcode...\n";
   if (OutputAssembly) {
-    *Out << *Composite;
-  } else if (Force || !CheckBitcodeOutputToConsole(*Out, true))
-    WriteBitcodeToFile(Composite.get(), *Out);
+    Out << *Composite;
+  } else if (Force || !CheckBitcodeOutputToConsole(Out, true))
+    WriteBitcodeToFile(Composite.get(), Out);
+
+  // Declare success.
+  Out.keep();
 
   return 0;
 }





More information about the llvm-commits mailing list