summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clangd/ClangdServer.cpp4
-rw-r--r--clang-tools-extra/clangd/Function.h34
2 files changed, 3 insertions, 35 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index 588cbac63c7..46c9204149c 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -19,6 +19,7 @@
#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
#include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatProviders.h"
@@ -576,7 +577,8 @@ std::future<Context> ClangdServer::scheduleReparseAndDiags(
const Context &)>
DeferredRebuild,
std::promise<Context> DonePromise, Context Ctx) -> void {
- auto Guard = onScopeExit([&]() { DonePromise.set_value(std::move(Ctx)); });
+ auto Guard =
+ llvm::make_scope_exit([&]() { DonePromise.set_value(std::move(Ctx)); });
auto CurrentVersion = DraftMgr.getVersion(FileStr);
if (CurrentVersion != Version)
diff --git a/clang-tools-extra/clangd/Function.h b/clang-tools-extra/clangd/Function.h
index 8d1da07d095..7836cd222f9 100644
--- a/clang-tools-extra/clangd/Function.h
+++ b/clang-tools-extra/clangd/Function.h
@@ -137,40 +137,6 @@ ForwardBinder<Func, Args...> BindWithForward(Func F, Args &&... As) {
std::make_tuple(std::forward<Func>(F), std::forward<Args>(As)...));
}
-namespace detail {
-/// Runs provided callback in destructor. Use onScopeExit helper function to
-/// create this object.
-template <class Func> struct ScopeExitGuard {
- static_assert(std::is_same<typename std::decay<Func>::type, Func>::value,
- "Func must be decayed");
-
- ScopeExitGuard(Func F) : F(std::move(F)) {}
- ~ScopeExitGuard() {
- if (!F)
- return;
- (*F)();
- }
-
- // Move-only.
- ScopeExitGuard(const ScopeExitGuard &) = delete;
- ScopeExitGuard &operator=(const ScopeExitGuard &) = delete;
-
- ScopeExitGuard(ScopeExitGuard &&Other) = default;
- ScopeExitGuard &operator=(ScopeExitGuard &&Other) = default;
-
-private:
- llvm::Optional<Func> F;
-};
-} // namespace detail
-
-/// Creates a RAII object that will run \p F in its destructor.
-template <class Func>
-auto onScopeExit(Func &&F)
- -> detail::ScopeExitGuard<typename std::decay<Func>::type> {
- return detail::ScopeExitGuard<typename std::decay<Func>::type>(
- std::forward<Func>(F));
-}
-
} // namespace clangd
} // namespace clang
OpenPOWER on IntegriCloud