[PATCH] D48337: Refactor OnExit utility class in ClangUserExpression

Raphael Isemann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 19 14:30:48 PDT 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335078: Refactor OnExit utility class in ClangUserExpression (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48337?vs=151978&id=151980#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48337

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


Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -307,6 +307,21 @@
 #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 @@
 
   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 @@
               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 @@
     }
   }
 
-  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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48337.151980.patch
Type: text/x-patch
Size: 2226 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180619/676a4f7a/attachment.bin>


More information about the llvm-commits mailing list