LCOV - code coverage report
Current view: top level - lib/Support - ToolOutputFile.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 18 19 94.7 %
Date: 2017-09-14 15:23:50 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/Support/ToolOutputFile.h"
      15             : #include "llvm/Support/FileSystem.h"
      16             : #include "llvm/Support/Signals.h"
      17             : using namespace llvm;
      18             : 
      19       32672 : tool_output_file::CleanupInstaller::CleanupInstaller(StringRef Filename)
      20       32672 :     : Filename(Filename), Keep(false) {
      21             :   // Arrange for the file to be deleted if the process is killed.
      22       32672 :   if (Filename != "-")
      23        3662 :     sys::RemoveFileOnSignal(Filename);
      24       32672 : }
      25             : 
      26       97380 : tool_output_file::CleanupInstaller::~CleanupInstaller() {
      27             :   // Delete the file if the client hasn't told us not to.
      28       33580 :   if (!Keep && Filename != "-")
      29         532 :     sys::fs::remove(Filename);
      30             : 
      31             :   // Ok, the file is successfully written and closed, or deleted. There's no
      32             :   // further need to clean it up on signals.
      33       64920 :   if (Filename != "-")
      34        7270 :     sys::DontRemoveFileOnSignal(Filename);
      35       32460 : }
      36             : 
      37       32258 : tool_output_file::tool_output_file(StringRef Filename, std::error_code &EC,
      38       32258 :                                    sys::fs::OpenFlags Flags)
      39       32258 :     : Installer(Filename), OS(Filename, EC, Flags) {
      40             :   // If open fails, no cleanup is needed.
      41       32258 :   if (EC)
      42           0 :     Installer.Keep = true;
      43       32258 : }
      44             : 
      45         414 : tool_output_file::tool_output_file(StringRef Filename, int FD)
      46         414 :     : Installer(Filename), OS(FD, true) {}

Generated by: LCOV version 1.13