zpu: wip - add pass to convert registers to stack slots
[llvm/zpu.git] / lib / Support / ToolOutputFile.cpp
blob5b5ee6610a02d2d38fce8114d5fb335fa772567f
1 //===--- ToolOutputFile.cpp - Implement the tool_output_file class --------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This implements the tool_output_file class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/ToolOutputFile.h"
15 #include "llvm/System/Signals.h"
16 using namespace llvm;
18 tool_output_file::CleanupInstaller::CleanupInstaller(const char *filename)
19 : Filename(filename), Keep(false) {
20 // Arrange for the file to be deleted if the process is killed.
21 if (Filename != "-")
22 sys::RemoveFileOnSignal(sys::Path(Filename));
25 tool_output_file::CleanupInstaller::~CleanupInstaller() {
26 // Delete the file if the client hasn't told us not to.
27 if (!Keep && Filename != "-")
28 sys::Path(Filename).eraseFromDisk();
30 // Ok, the file is successfully written and closed, or deleted. There's no
31 // further need to clean it up on signals.
32 if (Filename != "-")
33 sys::DontRemoveFileOnSignal(sys::Path(Filename));
36 tool_output_file::tool_output_file(const char *filename, std::string &ErrorInfo,
37 unsigned Flags)
38 : Installer(filename),
39 OS(filename, ErrorInfo, Flags) {
40 // If open fails, no cleanup is needed.
41 if (!ErrorInfo.empty())
42 Installer.Keep = true;