LCOV - code coverage report
Current view: top level - include/llvm/Support - ToolOutputFile.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 3 3 100.0 %
Date: 2017-09-14 15:23:50 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- ToolOutputFile.h - Output files for compiler-like tools -----------===//
       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 file defines the tool_output_file class.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_SUPPORT_TOOLOUTPUTFILE_H
      15             : #define LLVM_SUPPORT_TOOLOUTPUTFILE_H
      16             : 
      17             : #include "llvm/Support/raw_ostream.h"
      18             : 
      19             : namespace llvm {
      20             : 
      21             : /// This class contains a raw_fd_ostream and adds a few extra features commonly
      22             : /// needed for compiler-like tool output files:
      23             : ///   - The file is automatically deleted if the process is killed.
      24             : ///   - The file is automatically deleted when the tool_output_file
      25             : ///     object is destroyed unless the client calls keep().
      26       32460 : class tool_output_file {
      27             :   /// This class is declared before the raw_fd_ostream so that it is constructed
      28             :   /// before the raw_fd_ostream is constructed and destructed after the
      29             :   /// raw_fd_ostream is destructed. It installs cleanups in its constructor and
      30             :   /// uninstalls them in its destructor.
      31             :   class CleanupInstaller {
      32             :     /// The name of the file.
      33             :     std::string Filename;
      34             :   public:
      35             :     /// The flag which indicates whether we should not delete the file.
      36             :     bool Keep;
      37             : 
      38             :     explicit CleanupInstaller(StringRef ilename);
      39             :     ~CleanupInstaller();
      40             :   } Installer;
      41             : 
      42             :   /// The contained stream. This is intentionally declared after Installer.
      43             :   raw_fd_ostream OS;
      44             : 
      45             : public:
      46             :   /// This constructor's arguments are passed to to raw_fd_ostream's
      47             :   /// constructor.
      48             :   tool_output_file(StringRef Filename, std::error_code &EC,
      49             :                    sys::fs::OpenFlags Flags);
      50             : 
      51             :   tool_output_file(StringRef Filename, int FD);
      52             : 
      53             :   /// Return the contained raw_fd_ostream.
      54       27943 :   raw_fd_ostream &os() { return OS; }
      55             : 
      56             :   /// Indicate that the tool's job wrt this output file has been successful and
      57             :   /// the file should not be deleted.
      58       31346 :   void keep() { Installer.Keep = true; }
      59             : };
      60             : 
      61             : } // end llvm namespace
      62             : 
      63             : #endif

Generated by: LCOV version 1.13