Skip to content

Commit 2385486

Browse files
committed
[LLVM][ADT] Make scope-exit CTAD-capable
1 parent b1d0e5f commit 2385486

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,14 +774,13 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
774774
// This will be the address of the storage for paths, if we are using them,
775775
// or nullptr to signal we aren't.
776776
lldb::addr_t path_array_addr = 0x0;
777-
std::optional<llvm::detail::scope_exit<std::function<void()>>>
778-
path_array_cleanup;
777+
std::optional<llvm::scope_exit<std::function<void()>>> path_array_cleanup;
779778

780779
// This is the address to a buffer large enough to hold the largest path
781780
// conjoined with the library name we're passing in. This is a convenience
782781
// to avoid having to call malloc in the dlopen function.
783782
lldb::addr_t buffer_addr = 0x0;
784-
std::optional<llvm::detail::scope_exit<std::function<void()>>> buffer_cleanup;
783+
std::optional<llvm::scope_exit<std::function<void()>>> buffer_cleanup;
785784

786785
// Set the values into our args and write them to the target:
787786
if (paths != nullptr) {

lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
231231

232232
/* Inject paths parameter into inferior */
233233
lldb::addr_t injected_paths{0x0};
234-
std::optional<llvm::detail::scope_exit<std::function<void()>>> paths_cleanup;
234+
std::optional<llvm::scope_exit<std::function<void()>>> paths_cleanup;
235235
if (paths) {
236236
llvm::SmallVector<llvm::UTF16, 261> search_paths;
237237

llvm/include/llvm/ADT/ScopeExit.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515
#ifndef LLVM_ADT_SCOPEEXIT_H
1616
#define LLVM_ADT_SCOPEEXIT_H
1717

18-
#include "llvm/Support/Compiler.h"
19-
20-
#include <type_traits>
2118
#include <utility>
2219

2320
namespace llvm {
24-
namespace detail {
2521

2622
template <typename Callable> class scope_exit {
2723
Callable ExitFunction;
@@ -47,17 +43,15 @@ template <typename Callable> class scope_exit {
4743
}
4844
};
4945

50-
} // end namespace detail
46+
template <typename Callable> scope_exit(Callable) -> scope_exit<Callable>;
5147

5248
// Keeps the callable object that is passed in, and execute it at the
5349
// destruction of the returned object (usually at the scope exit where the
5450
// returned object is kept).
5551
//
5652
// Interface is specified by p0052r2.
57-
template <typename Callable>
58-
[[nodiscard]] detail::scope_exit<std::decay_t<Callable>>
59-
make_scope_exit(Callable &&F) {
60-
return detail::scope_exit<std::decay_t<Callable>>(std::forward<Callable>(F));
53+
template <typename Callable> [[nodiscard]] auto make_scope_exit(Callable &&F) {
54+
return scope_exit(std::forward<Callable>(F));
6155
}
6256

6357
} // end namespace llvm

0 commit comments

Comments
 (0)