[lldb] Provide a getter for m_materializer_up in LLVMUserExpression instead of relyin...
authorRaphael Isemann <teemperor@gmail.com>
Mon, 4 Nov 2019 08:05:24 +0000 (09:05 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Mon, 4 Nov 2019 08:05:24 +0000 (09:05 +0100)
Summary:
Motivated by Swift using the materializer in a few places which requires us to add this getter ourselves.
We also need a setter, but let's keep this minimal to unblock the downstream reverts in Swift.

Reviewers: davide

Reviewed By: davide

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

Differential Revision: https://reviews.llvm.org/D69714

lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/LLVMUserExpression.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

index 2f0183c..fca5fb9 100644 (file)
@@ -64,6 +64,10 @@ public:
   /// default, return eLanguageTypeUnknown.
   virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
 
+  /// Return the Materializer that the parser should use when registering
+  /// external values.
+  virtual Materializer *GetMaterializer() { return nullptr; }
+
   /// Return the desired result type of the function, or eResultTypeAny if
   /// indifferent.
   virtual ResultType DesiredResultType() { return eResultTypeAny; }
index c3b8ed5..5f4c43c 100644 (file)
@@ -63,6 +63,8 @@ public:
 
   bool CanInterpret() override { return m_can_interpret; }
 
+  Materializer *GetMaterializer() override { return m_materializer_up.get(); }
+
   /// Return the string that the parser should parse.  Must be a full
   /// translation unit.
   const char *Text() override { return m_transformed_text.c_str(); }
index da1ca78..60592ca 100644 (file)
@@ -576,7 +576,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
 
   auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
 
-  if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
+  if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) {
     diagnostic_manager.PutString(
         eDiagnosticSeverityError,
         "current process state is unsuitable for expression parsing");
@@ -764,7 +764,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
 
   auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
 
-  if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
+  if (!DeclMap()->WillParse(exe_ctx, GetMaterializer())) {
     diagnostic_manager.PutString(
         eDiagnosticSeverityError,
         "current process state is unsuitable for expression parsing");