diff options
author | Raphael Isemann <teemperor@gmail.com> | 2018-06-19 21:25:59 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2018-06-19 21:25:59 +0000 |
commit | 1246890964c78b6ee1a453dc2746e8af0ec9479e (patch) | |
tree | 30c7c82318fd3830e4d720ea62bea2d34b986fd3 | |
parent | 8befa295ea5436dcf4643a02f0fb6ec125f7cff3 (diff) | |
download | bcm5719-llvm-1246890964c78b6ee1a453dc2746e8af0ec9479e.tar.gz bcm5719-llvm-1246890964c78b6ee1a453dc2746e8af0ec9479e.zip |
Refactor OnExit utility class in ClangUserExpression
Summary:
OnExit ensures we call `ResetDeclMap` before this method ends. However,
we also have a few manual calls to ResetDeclMap in there that are actually unnecessary
because of this (calling the method multiple times has no effect). This patch also moves
the class out of the method that we can reuse it for the upcoming method that handles
parsing for completion.
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D48337
llvm-svn: 335078
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 4da5492b14d..bb0788e32c6 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -307,6 +307,21 @@ static void ApplyObjcCastHack(std::string &expr) { #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::Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy, @@ -426,28 +441,12 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory); - class OnExit { - public: - typedef std::function<void(void)> Callback; - - OnExit(Callback const &callback) : m_callback(callback) {} - - ~OnExit() { m_callback(); } - - private: - Callback m_callback; - }; - OnExit on_exit([this]() { ResetDeclMap(); }); if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) { diagnostic_manager.PutString( eDiagnosticSeverityError, "current process state is unsuitable for expression parsing"); - - ResetDeclMap(); // We are being careful here in the case of breakpoint - // conditions. - return false; } @@ -484,10 +483,6 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, fixed_expression.substr(fixed_start, fixed_end - fixed_start); } } - - ResetDeclMap(); // We are being careful here in the case of breakpoint - // conditions. - return false; } @@ -565,10 +560,6 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, } } - ResetDeclMap(); // Make this go away since we don't need any of its state - // after parsing. This also gets rid of any - // ClangASTImporter::Minions. - if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS) m_jit_process_wp = lldb::ProcessWP(process->shared_from_this()); return true; |