mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 17:43:57 +00:00
Replace local utility class OnExit with llvm::scope_exit (NFC)
llvm-svn: 359319
This commit is contained in:
parent
354247c08d
commit
edebf12acf
@ -56,6 +56,8 @@
|
|||||||
#include "clang/AST/DeclCXX.h"
|
#include "clang/AST/DeclCXX.h"
|
||||||
#include "clang/AST/DeclObjC.h"
|
#include "clang/AST/DeclObjC.h"
|
||||||
|
|
||||||
|
#include "llvm/ADT/ScopeExit.h"
|
||||||
|
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
ClangUserExpression::ClangUserExpression(
|
ClangUserExpression::ClangUserExpression(
|
||||||
@ -328,21 +330,6 @@ static void ApplyObjcCastHack(std::string &expr) {
|
|||||||
#undef OBJC_CAST_HACK_FROM
|
#undef OBJC_CAST_HACK_FROM
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
// Utility guard that calls a callback when going out of scope.
|
|
||||||
class OnExit {
|
|
||||||
public:
|
|
||||||
typedef std::function<void(void)> Callback;
|
|
||||||
|
|
||||||
OnExit(Callback const &callback) : m_callback(callback) {}
|
|
||||||
|
|
||||||
~OnExit() { m_callback(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Callback m_callback;
|
|
||||||
};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_manager,
|
bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_manager,
|
||||||
ExecutionContext &exe_ctx) {
|
ExecutionContext &exe_ctx) {
|
||||||
if (Target *target = exe_ctx.GetTargetPtr()) {
|
if (Target *target = exe_ctx.GetTargetPtr()) {
|
||||||
@ -560,7 +547,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
|
|||||||
|
|
||||||
ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
|
ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
|
||||||
|
|
||||||
OnExit on_exit([this]() { ResetDeclMap(); });
|
auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
|
||||||
|
|
||||||
if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
|
if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
|
||||||
diagnostic_manager.PutString(
|
diagnostic_manager.PutString(
|
||||||
@ -748,7 +735,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
|
|||||||
|
|
||||||
ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true);
|
ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true);
|
||||||
|
|
||||||
OnExit on_exit([this]() { ResetDeclMap(); });
|
auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
|
||||||
|
|
||||||
if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
|
if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
|
||||||
diagnostic_manager.PutString(
|
diagnostic_manager.PutString(
|
||||||
|
Loading…
Reference in New Issue
Block a user