Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Support/ToolOutputFile.cpp
Line
Count
Source
1
//===--- ToolOutputFile.cpp - Implement the ToolOutputFile class --------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This implements the ToolOutputFile class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/Support/ToolOutputFile.h"
14
#include "llvm/Support/FileSystem.h"
15
#include "llvm/Support/Signals.h"
16
using namespace llvm;
17
18
ToolOutputFile::CleanupInstaller::CleanupInstaller(StringRef Filename)
19
51.0k
    : Filename(Filename), Keep(false) {
20
51.0k
  // Arrange for the file to be deleted if the process is killed.
21
51.0k
  if (Filename != "-")
22
5.90k
    sys::RemoveFileOnSignal(Filename);
23
51.0k
}
24
25
50.7k
ToolOutputFile::CleanupInstaller::~CleanupInstaller() {
26
50.7k
  // Delete the file if the client hasn't told us not to.
27
50.7k
  if (!Keep && 
Filename != "-"2.88k
)
28
376
    sys::fs::remove(Filename);
29
50.7k
30
50.7k
  // Ok, the file is successfully written and closed, or deleted. There's no
31
50.7k
  // further need to clean it up on signals.
32
50.7k
  if (Filename != "-")
33
5.82k
    sys::DontRemoveFileOnSignal(Filename);
34
50.7k
}
35
36
ToolOutputFile::ToolOutputFile(StringRef Filename, std::error_code &EC,
37
                               sys::fs::OpenFlags Flags)
38
51.0k
    : Installer(Filename), OS(Filename, EC, Flags) {
39
51.0k
  // If open fails, no cleanup is needed.
40
51.0k
  if (EC)
41
1
    Installer.Keep = true;
42
51.0k
}
43
44
ToolOutputFile::ToolOutputFile(StringRef Filename, int FD)
45
25
    : Installer(Filename), OS(FD, true) {}