Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,14 +774,13 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
// This will be the address of the storage for paths, if we are using them,
// or nullptr to signal we aren't.
lldb::addr_t path_array_addr = 0x0;
std::optional<llvm::detail::scope_exit<std::function<void()>>>
path_array_cleanup;
std::optional<llvm::scope_exit<std::function<void()>>> path_array_cleanup;

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

// Set the values into our args and write them to the target:
if (paths != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,

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

Expand Down
12 changes: 3 additions & 9 deletions llvm/include/llvm/ADT/ScopeExit.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
#ifndef LLVM_ADT_SCOPEEXIT_H
#define LLVM_ADT_SCOPEEXIT_H

#include "llvm/Support/Compiler.h"

#include <type_traits>
#include <utility>

namespace llvm {
namespace detail {

template <typename Callable> class scope_exit {
Callable ExitFunction;
Expand All @@ -47,17 +43,15 @@ template <typename Callable> class scope_exit {
}
};

} // end namespace detail
template <typename Callable> scope_exit(Callable) -> scope_exit<Callable>;

// Keeps the callable object that is passed in, and execute it at the
// destruction of the returned object (usually at the scope exit where the
// returned object is kept).
//
// Interface is specified by p0052r2.
template <typename Callable>
[[nodiscard]] detail::scope_exit<std::decay_t<Callable>>
make_scope_exit(Callable &&F) {
return detail::scope_exit<std::decay_t<Callable>>(std::forward<Callable>(F));
template <typename Callable> [[nodiscard]] auto make_scope_exit(Callable &&F) {
return scope_exit(std::forward<Callable>(F));
}

} // end namespace llvm
Expand Down