[llvm] [Support] Make CleanupInstaller public (NFC) (PR #86758)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 19:23:13 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Haohai Wen (HaohaiWen)
<details>
<summary>Changes</summary>
This can be used by others to automatically remove temp files.
---
Full diff: https://github.com/llvm/llvm-project/pull/86758.diff
2 Files Affected:
- (modified) llvm/include/llvm/Support/ToolOutputFile.h (+14-12)
- (modified) llvm/lib/Support/ToolOutputFile.cpp (+2-2)
``````````diff
diff --git a/llvm/include/llvm/Support/ToolOutputFile.h b/llvm/include/llvm/Support/ToolOutputFile.h
index e3fb83fdfd2c3f..c16fb03d9b22b9 100644
--- a/llvm/include/llvm/Support/ToolOutputFile.h
+++ b/llvm/include/llvm/Support/ToolOutputFile.h
@@ -18,6 +18,19 @@
namespace llvm {
+class CleanupInstaller {
+public:
+ /// The name of the file.
+ std::string Filename;
+
+ /// The flag which indicates whether we should not delete the file.
+ bool Keep;
+
+ StringRef getFilename() { return Filename; }
+ explicit CleanupInstaller(StringRef Filename);
+ ~CleanupInstaller();
+};
+
/// This class contains a raw_fd_ostream and adds a few extra features commonly
/// needed for compiler-like tool output files:
/// - The file is automatically deleted if the process is killed.
@@ -28,18 +41,7 @@ class ToolOutputFile {
/// before the raw_fd_ostream is constructed and destructed after the
/// raw_fd_ostream is destructed. It installs cleanups in its constructor and
/// uninstalls them in its destructor.
- class CleanupInstaller {
- public:
- /// The name of the file.
- std::string Filename;
-
- /// The flag which indicates whether we should not delete the file.
- bool Keep;
-
- StringRef getFilename() { return Filename; }
- explicit CleanupInstaller(StringRef Filename);
- ~CleanupInstaller();
- } Installer;
+ CleanupInstaller Installer;
/// Storage for the stream, if we're owning our own stream. This is
/// intentionally declared after Installer.
diff --git a/llvm/lib/Support/ToolOutputFile.cpp b/llvm/lib/Support/ToolOutputFile.cpp
index 01f7095f3499d9..7a07286882fee0 100644
--- a/llvm/lib/Support/ToolOutputFile.cpp
+++ b/llvm/lib/Support/ToolOutputFile.cpp
@@ -17,14 +17,14 @@ using namespace llvm;
static bool isStdout(StringRef Filename) { return Filename == "-"; }
-ToolOutputFile::CleanupInstaller::CleanupInstaller(StringRef Filename)
+CleanupInstaller::CleanupInstaller(StringRef Filename)
: Filename(std::string(Filename)), Keep(false) {
// Arrange for the file to be deleted if the process is killed.
if (!isStdout(Filename))
sys::RemoveFileOnSignal(Filename);
}
-ToolOutputFile::CleanupInstaller::~CleanupInstaller() {
+CleanupInstaller::~CleanupInstaller() {
if (isStdout(Filename))
return;
``````````
</details>
https://github.com/llvm/llvm-project/pull/86758
More information about the llvm-commits
mailing list