diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2018-02-18 16:05:40 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2018-02-18 16:05:40 +0000 |
commit | 92387a87447f79da2ad35eab11fdc99c97731448 (patch) | |
tree | d698334c5336d07fa0dd522ae30bbfbb2a2cbcc7 /llvm/lib/Support/LockFileManager.cpp | |
parent | aed6e52b3c3f5f988d89c440a0a9711a4ecba40a (diff) | |
download | bcm5719-llvm-92387a87447f79da2ad35eab11fdc99c97731448.tar.gz bcm5719-llvm-92387a87447f79da2ad35eab11fdc99c97731448.zip |
[Support] Replace hand-written scope_exit with make_scope_exit.
No functionality change intended.
llvm-svn: 325460
Diffstat (limited to 'llvm/lib/Support/LockFileManager.cpp')
-rw-r--r-- | llvm/lib/Support/LockFileManager.cpp | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index ec951f33a36..74cb8fea408 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -9,6 +9,7 @@ #include "llvm/Support/LockFileManager.h" #include "llvm/ADT/None.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Errc.h" @@ -121,27 +122,6 @@ bool LockFileManager::processStillExecuting(StringRef HostID, int PID) { return true; } -namespace { - -/// An RAII helper object for cleanups. -class RAIICleanup { - std::function<void()> Fn; - bool Canceled = false; - -public: - RAIICleanup(std::function<void()> Fn) : Fn(Fn) {} - - ~RAIICleanup() { - if (Canceled) - return; - Fn(); - } - - void cancel() { Canceled = true; } -}; - -} // end anonymous namespace - LockFileManager::LockFileManager(StringRef FileName) { this->FileName = FileName; @@ -172,7 +152,7 @@ LockFileManager::LockFileManager(StringRef FileName) UniqueLockFile = std::move(*Temp); // Make sure we discard the temporary file on exit. - RAIICleanup RemoveTempFile([&]() { + auto RemoveTempFile = llvm::make_scope_exit([&]() { if (Error E = UniqueLockFile->discard()) setError(errorToErrorCode(std::move(E))); }); @@ -209,7 +189,7 @@ LockFileManager::LockFileManager(StringRef FileName) std::error_code EC = sys::fs::create_link(UniqueLockFile->TmpName, LockFileName); if (!EC) { - RemoveTempFile.cancel(); + RemoveTempFile.release(); return; } |