[Lldb-commits] [lldb] r359319 - Replace local utility class OnExit with llvm::scope_exit (NFC)

Tatyana Krasnukha via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 26 09:41:05 PDT 2019


Author: tkrasnukha
Date: Fri Apr 26 09:41:04 2019
New Revision: 359319

URL: http://llvm.org/viewvc/llvm-project?rev=359319&view=rev
Log:
Replace local utility class OnExit with llvm::scope_exit (NFC)

Modified:
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=359319&r1=359318&r2=359319&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Fri Apr 26 09:41:04 2019
@@ -56,6 +56,8 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 
+#include "llvm/ADT/ScopeExit.h"
+
 using namespace lldb_private;
 
 ClangUserExpression::ClangUserExpression(
@@ -328,21 +330,6 @@ static void ApplyObjcCastHack(std::strin
 #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,
                                  ExecutionContext &exe_ctx) {
   if (Target *target = exe_ctx.GetTargetPtr()) {
@@ -560,7 +547,7 @@ bool ClangUserExpression::Parse(Diagnost
 
   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())) {
     diagnostic_manager.PutString(
@@ -748,7 +735,7 @@ bool ClangUserExpression::Complete(Execu
 
   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())) {
     diagnostic_manager.PutString(




More information about the lldb-commits mailing list