[Lldb-commits] [lldb] ff0102b - [lldb] Remove modern-type-lookup

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 17 03:25:11 PST 2019


Author: Raphael Isemann
Date: 2019-12-17T12:24:31+01:00
New Revision: ff0102b32cfe506dfc16a86e38e70b0940697aa2

URL: https://github.com/llvm/llvm-project/commit/ff0102b32cfe506dfc16a86e38e70b0940697aa2
DIFF: https://github.com/llvm/llvm-project/commit/ff0102b32cfe506dfc16a86e38e70b0940697aa2.diff

LOG: [lldb] Remove modern-type-lookup

Summary:
As discussed on the mailing list [1] we have to make a decision for how to proceed with the modern-type-lookup.

This patch removes modern-type-lookup from LLDB. This just removes all the code behind the modern-type-lookup
setting but it does *not* remove any code from Clang (i.e., the ExternalASTMerger and the clang-import-test stay around
for now).

The motivation for this is that I don't think that the current approach of implementing modern-type-lookup
will work out. Especially creating a completely new lookup system behind some setting that is never turned on by anyone
and then one day make one big switch to the new system seems wrong. It doesn't fit into the way LLVM is developed and has
so far made the transition work much more complicated than it has to be.

A lot of the benefits that were supposed to come with the modern-type-lookup are related to having a better organization
in the way types move across LLDB and having less dependencies on unrelated LLDB code. By just looking at the current code (mostly
the ClangASTImporter) I think we can reach the same goals by just incrementally cleaning up, documenting, refactoring
and actually testing the existing code we have.

[1] http://lists.llvm.org/pipermail/lldb-dev/2019-December/015831.html

Reviewers: shafik, martong

Subscribers: rnkovacs, christof, arphaman, JDevlieghere, usaxena95, lldb-commits, friss

Tags: #lldb

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

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/ClangASTContext.h
    lldb/include/lldb/Target/Target.h
    lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
    lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
    lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
    lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
    lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
    lldb/source/Symbol/ClangASTContext.cpp
    lldb/source/Target/Target.cpp
    lldb/source/Target/TargetProperties.td

Removed: 
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/Makefile
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/TestObjModulesModernTypeLookup.py
    lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/main.m


################################################################################
diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 5d228e7bdad7..9c37b94219f0 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -21,7 +21,6 @@
 #include <vector>
 
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/ExternalASTMerger.h"
 #include "clang/AST/TemplateBase.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/SmallVector.h"
@@ -965,10 +964,7 @@ class ClangASTContext : public TypeSystem {
 
   clang::DeclarationName
   GetDeclarationName(const char *name, const CompilerType &function_clang_type);
-  
-  virtual const clang::ExternalASTMerger::OriginMap &GetOriginMap() {
-    return m_origins;
-  }
+
 protected:
   const clang::ClassTemplateSpecializationDecl *
   GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
@@ -993,7 +989,6 @@ class ClangASTContext : public TypeSystem {
   CompleteTagDeclCallback m_callback_tag_decl = nullptr;
   CompleteObjCInterfaceDeclCallback m_callback_objc_decl = nullptr;
   void *m_callback_baton = nullptr;
-  clang::ExternalASTMerger::OriginMap m_origins;
   uint32_t m_pointer_byte_size = 0;
   bool m_ast_owned = false;
   /// The sema associated that is currently used to build this ASTContext.
@@ -1032,12 +1027,6 @@ class ClangASTContextForExpressions : public ClangASTContext {
                                       const char *name) override;
 
   PersistentExpressionState *GetPersistentExpressionState() override;
-  
-  clang::ExternalASTMerger &GetMergerUnchecked();
-  
-  const clang::ExternalASTMerger::OriginMap &GetOriginMap() override {
-    return GetMergerUnchecked().GetOrigins();
-  }
 private:
   lldb::TargetWP m_target_wp;
   std::unique_ptr<PersistentExpressionState>

diff  --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 29384fa29fd3..6f8d60731acf 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -203,8 +203,6 @@ class TargetProperties : public Properties {
 
   void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
 
-  bool GetUseModernTypeLookup() const;
-
   void SetRequireHardwareBreakpoints(bool b);
 
   bool GetRequireHardwareBreakpoints() const;

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile
deleted file mode 100644
index afecbf969483..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-OBJC_SOURCES := main.m
-LD_EXTRAS := -lobjc -framework Foundation
-
-include Makefile.rules

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py
deleted file mode 100644
index 700b3ecbe6bb..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class TestBasicObjcModernTypeLookup(TestBase):
-  mydir = TestBase.compute_mydir(__file__)
-
-  @skipUnlessDarwin
-  def test(self):
-    self.build()
-    # Activate modern-type-lookup.
-    # FIXME: This has to happen before we create any target otherwise we crash...
-    self.runCmd("settings set target.experimental.use-modern-type-lookup true")
-    (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self,
-          "break here", lldb.SBFileSpec("main.m"))
-    self.expect("expr 1", substrs=["(int) ", " = 1"])
-    self.expect("expr (int)[Foo bar:22]", substrs=["(int) ", " = 44"])

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m
deleted file mode 100644
index b427971e7bea..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m
+++ /dev/null
@@ -1,17 +0,0 @@
-#import <Foundation/Foundation.h>
-
- at interface Foo : NSObject
-+(int) bar: (int) string;
- at end
-
- at implementation Foo
-+(int) bar: (int) x
-{
-  return x + x;
-}
- at end
-
-int main() {
-  NSLog(@"Hello World");
-  return 0; // break here
-}

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile
deleted file mode 100644
index 3d0b98f13f3d..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-CXX_SOURCES := main.cpp
-include Makefile.rules

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py
deleted file mode 100644
index 613fb95658bf..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class BasicModernTypeLookup(TestBase):
-
-    mydir = TestBase.compute_mydir(__file__)
-
-    def test(self):
-        self.build()
-
-        # Activate modern-type-lookup.
-        self.runCmd("settings set target.experimental.use-modern-type-lookup true")
-
-        lldbutil.run_to_source_breakpoint(self,
-            "// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
-
-        # Test a few simple expressions that should still work with modern-type-lookup.
-        self.expect("expr 1", substrs=["(int) ", " = 1\n"])
-        self.expect("expr f.x", substrs=["(int) ", " = 44\n"])
-        self.expect("expr f", substrs=["(Foo) ", "x = 44"])

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp
deleted file mode 100644
index e0c3ead7f757..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-struct Foo { int x; };
-
-int main(int argc, char **argv) {
-  Foo f;
-  f.x = 44;
-  return f.x; // Set break point at this line.
-}

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile
deleted file mode 100644
index 574c53d7cb1c..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-USE_LIBCPP := 1
-include Makefile.rules

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
deleted file mode 100644
index b780677e709e..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class LibcxxModernTypeLookup(TestBase):
-
-    mydir = TestBase.compute_mydir(__file__)
-
-    @add_test_categories(["libc++"])
-    def test(self):
-        self.build()
-
-        # Activate modern-type-lookup.
-        self.runCmd("settings set target.experimental.use-modern-type-lookup true")
-
-        lldbutil.run_to_source_breakpoint(self,
-            "// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
-
-        # Test a few simple expressions that should still work with modern-type-lookup.
-        self.expect("expr pair", substrs=["(std::", "pair<int, long", "= (first = 1, second = 2)"])
-        self.expect("expr foo", substrs=["(std::", "string", "\"bar\""])
-        self.expect("expr map", substrs=["(std::", "map", "first = 1, second = 2"])
-        self.expect("expr umap", substrs=["(std::", "unordered_map", "first = 1, second = 2"])

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
deleted file mode 100644
index 50cc8b1f61cc..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <utility>
-#include <string>
-#include <map>
-#include <unordered_map>
-
-int main(int argc, char **argv) {
-  std::pair<int, long> pair = std::make_pair<int, float>(1, 2L);
-  std::string foo = "bar";
-  std::map<int, int> map;
-  map[1] = 2;
-  std::unordered_map<int, int> umap;
-  umap[1] = 2;
-  return pair.first; // Set break point at this line.
-}

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/Makefile
deleted file mode 100644
index afecbf969483..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-OBJC_SOURCES := main.m
-LD_EXTRAS := -lobjc -framework Foundation
-
-include Makefile.rules

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/TestObjModulesModernTypeLookup.py b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/TestObjModulesModernTypeLookup.py
deleted file mode 100644
index 3983263bd65b..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/TestObjModulesModernTypeLookup.py
+++ /dev/null
@@ -1,26 +0,0 @@
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class TestObjcModulesModernTypeLookup(TestBase):
-  mydir = TestBase.compute_mydir(__file__)
-
-  @skipUnlessDarwin
-  # gmodules causes this to crash as we seem to get a NSURL type from the debug information.
-  @skipIf(debug_info="gmodules")
-  def test(self):
-    self.build()
-    # Activate modern-type-lookup.
-    # FIXME: This has to happen before we create any target otherwise we crash...
-    self.runCmd("settings set target.experimental.use-modern-type-lookup true")
-    (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self,
-          "break here", lldb.SBFileSpec("main.m"))
-    self.expect("expr @import Foundation")
-    self.expect(
-            "p *[NSURL URLWithString:@\"http://lldb.llvm.org\"]",
-            VARIABLES_DISPLAYED_CORRECTLY,
-            substrs=[
-                "NSURL",
-                "isa",
-                "_urlString"])

diff  --git a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/main.m b/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/main.m
deleted file mode 100644
index 9eb93f0e8c5f..000000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/main.m
+++ /dev/null
@@ -1,6 +0,0 @@
-#import <Foundation/Foundation.h>
-
-int main() {
-  NSLog(@"Hello World");
-  return 0; // break here
-}

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 58db9d4e7424..94a23c8069a1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -52,9 +52,7 @@ class ScopedLexicalDeclEraser {
 ClangASTSource::ClangASTSource(const lldb::TargetSP &target)
     : m_import_in_progress(false), m_lookups_enabled(false), m_target(target),
       m_ast_context(nullptr), m_active_lexical_decls(), m_active_lookups() {
-  if (!target->GetUseModernTypeLookup()) {
-    m_ast_importer_sp = m_target->GetClangASTImporter();
-  }
+  m_ast_importer_sp = m_target->GetClangASTImporter();
 }
 
 void ClangASTSource::InstallASTContext(ClangASTContext &clang_ast_context,
@@ -63,81 +61,7 @@ void ClangASTSource::InstallASTContext(ClangASTContext &clang_ast_context,
   m_ast_context = clang_ast_context.getASTContext();
   m_clang_ast_context = &clang_ast_context;
   m_file_manager = &file_manager;
-  if (m_target->GetUseModernTypeLookup()) {
-    // Configure the ExternalASTMerger.  The merger needs to be able to import
-    // types from any source that we would do lookups in, which includes the
-    // persistent AST context as well as the modules and Objective-C runtime
-    // AST contexts.
-
-    lldbassert(!m_merger_up);
-    clang::ExternalASTMerger::ImporterTarget target = {*m_ast_context,
-                                                       file_manager};
-    std::vector<clang::ExternalASTMerger::ImporterSource> sources;
-    for (lldb::ModuleSP module_sp : m_target->GetImages().Modules()) {
-      auto type_system_or_err =
-          module_sp->GetTypeSystemForLanguage(lldb::eLanguageTypeC);
-      if (auto err = type_system_or_err.takeError()) {
-        LLDB_LOG_ERROR(
-            lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS),
-            std::move(err), "Failed to get ClangASTContext");
-      } else if (auto *module_ast_ctx = llvm::cast_or_null<ClangASTContext>(
-                     &type_system_or_err.get())) {
-        lldbassert(module_ast_ctx->getASTContext());
-        lldbassert(module_ast_ctx->getFileManager());
-        sources.emplace_back(*module_ast_ctx->getASTContext(),
-                             *module_ast_ctx->getFileManager(),
-                             module_ast_ctx->GetOriginMap());
-      }
-    }
-
-    do {
-      lldb::ProcessSP process(m_target->GetProcessSP());
-
-      if (!process)
-        break;
-
-      ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process));
-
-      if (!language_runtime)
-        break;
-
-      if (auto *runtime_decl_vendor = llvm::dyn_cast_or_null<ClangDeclVendor>(
-              language_runtime->GetDeclVendor())) {
-        sources.push_back(runtime_decl_vendor->GetImporterSource());
-      }
-    } while (false);
-
-    do {
-      auto *modules_decl_vendor = m_target->GetClangModulesDeclVendor();
-
-      if (!modules_decl_vendor)
-        break;
-
-      sources.push_back(modules_decl_vendor->GetImporterSource());
-    } while (false);
-
-    if (!is_shared_context) {
-      // Update the scratch AST context's merger to reflect any new sources we
-      // might have come across since the last time an expression was parsed.
-
-      if (auto *clang_ast_context = ClangASTContext::GetScratch(*m_target)) {
-
-        auto scratch_ast_context =
-            static_cast<ClangASTContextForExpressions *>(clang_ast_context);
-
-        scratch_ast_context->GetMergerUnchecked().AddSources(sources);
-
-        sources.push_back({*scratch_ast_context->getASTContext(),
-                           *scratch_ast_context->getFileManager(),
-                           scratch_ast_context->GetOriginMap()});
-      }
-    }
-
-    m_merger_up =
-        std::make_unique<clang::ExternalASTMerger>(target, sources);
-  } else {
-    m_ast_importer_sp->InstallMapCompleter(m_ast_context, *this);
-  }
+  m_ast_importer_sp->InstallMapCompleter(m_ast_context, *this);
 }
 
 ClangASTSource::~ClangASTSource() {
@@ -293,9 +217,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
   ScopedLexicalDeclEraser eraser(m_active_lexical_decls, tag_decl);
 
   if (!m_ast_importer_sp) {
-    if (HasMerger()) {
-      GetMergerUnchecked().CompleteType(tag_decl);
-    }
     return;
   }
 
@@ -423,18 +344,7 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
            ClangUtil::DumpDecl(interface_decl));
 
   if (!m_ast_importer_sp) {
-    if (HasMerger()) {
-      ObjCInterfaceDecl *complete_iface_decl =
-        GetCompleteObjCInterface(interface_decl);
-
-      if (complete_iface_decl && (complete_iface_decl != interface_decl)) {
-        m_merger_up->ForceRecordOrigin(interface_decl, {complete_iface_decl, &complete_iface_decl->getASTContext()});
-      }
-
-      GetMergerUnchecked().CompleteType(interface_decl);
-    } else {
-      lldbassert(0 && "No mechanism for completing a type!");
-    }
+    lldbassert(0 && "No mechanism for completing a type!");
     return;
   }
 
@@ -510,19 +420,7 @@ void ClangASTSource::FindExternalLexicalDecls(
     llvm::function_ref<bool(Decl::Kind)> predicate,
     llvm::SmallVectorImpl<Decl *> &decls) {
 
-  if (HasMerger()) {
-    if (auto *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl_context)) {
-      ObjCInterfaceDecl *complete_iface_decl =
-         GetCompleteObjCInterface(interface_decl);
-
-      if (complete_iface_decl && (complete_iface_decl != interface_decl)) {
-        m_merger_up->ForceRecordOrigin(interface_decl, {complete_iface_decl, &complete_iface_decl->getASTContext()});
-      }
-    }
-    return GetMergerUnchecked().FindExternalLexicalDecls(decl_context,
-                                                         predicate,
-                                                         decls);
-  } else if (!m_ast_importer_sp)
+  if (!m_ast_importer_sp)
     return;
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -698,25 +596,6 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
                 name.GetCString(), context.m_decl_context->getDeclKindName());
   }
 
-  if (HasMerger() && !isa<TranslationUnitDecl>(context.m_decl_context)
-      /* possibly handle NamespaceDecls here? */) {
-    if (auto *interface_decl =
-    dyn_cast<ObjCInterfaceDecl>(context.m_decl_context)) {
-      ObjCInterfaceDecl *complete_iface_decl =
-      GetCompleteObjCInterface(interface_decl);
-
-      if (complete_iface_decl && (complete_iface_decl != interface_decl)) {
-        GetMergerUnchecked().ForceRecordOrigin(
-            interface_decl,
-            {complete_iface_decl, &complete_iface_decl->getASTContext()});
-      }
-    }
-
-    GetMergerUnchecked().FindExternalVisibleDeclsByName(context.m_decl_context,
-                                                context.m_decl_name);
-    return; // otherwise we may need to fall back
-  }
-
   context.m_namespace_map = std::make_shared<ClangASTImporter::NamespaceMap>();
 
   if (const NamespaceDecl *namespace_context =
@@ -741,7 +620,7 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
 
       FindExternalVisibleDecls(context, i->first, i->second, current_id);
     }
-  } else if (isa<ObjCInterfaceDecl>(context.m_decl_context) && !HasMerger()) {
+  } else if (isa<ObjCInterfaceDecl>(context.m_decl_context)) {
     FindObjCPropertyAndIvarDecls(context);
   } else if (!isa<TranslationUnitDecl>(context.m_decl_context)) {
     // we shouldn't be getting FindExternalVisibleDecls calls for these
@@ -820,7 +699,7 @@ void ClangASTSource::FindExternalVisibleDecls(
                   module_sp->GetFileSpec().GetFilename().GetCString());
       }
     }
-  } else if (!HasMerger()) {
+  } else {
     const ModuleList &target_images = m_target->GetImages();
     std::lock_guard<std::recursive_mutex> guard(target_images.GetMutex());
 
@@ -1131,21 +1010,6 @@ bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
 void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
-  if (HasMerger()) {
-    if (auto *interface_decl = dyn_cast<ObjCInterfaceDecl>(context.m_decl_context)) {
-      ObjCInterfaceDecl *complete_iface_decl =
-          GetCompleteObjCInterface(interface_decl);
-
-      if (complete_iface_decl && (complete_iface_decl != context.m_decl_context)) {
-        m_merger_up->ForceRecordOrigin(interface_decl, {complete_iface_decl, &complete_iface_decl->getASTContext()});
-      }
-    }
-
-    GetMergerUnchecked().FindExternalVisibleDeclsByName(context.m_decl_context,
-                                                        context.m_decl_name);
-    return;
-  }
-
   static unsigned int invocation_id = 0;
   unsigned int current_id = invocation_id++;
 
@@ -1950,45 +1814,10 @@ NamespaceDecl *ClangASTSource::AddNamespace(
   return dyn_cast<NamespaceDecl>(copied_decl);
 }
 
-clang::QualType ClangASTSource::CopyTypeWithMerger(
-    clang::ASTContext &from_context,
-    clang::ExternalASTMerger &merger,
-    clang::QualType type) {
-  if (!merger.HasImporterForOrigin(from_context)) {
-    lldbassert(0 && "Couldn't find the importer for a source context!");
-    return QualType();
-  }
-
-  if (llvm::Expected<QualType> type_or_error =
-          merger.ImporterForOrigin(from_context).Import(type)) {
-    return *type_or_error;
-  } else {
-    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
-    LLDB_LOG_ERROR(log, type_or_error.takeError(), "Couldn't import type: {0}");
-    return QualType();
-  }
-}
-
 clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
   clang::ASTContext &from_context = src_decl->getASTContext();
   if (m_ast_importer_sp) {
     return m_ast_importer_sp->CopyDecl(m_ast_context, &from_context, src_decl);
-  } else if (m_merger_up) {
-    if (!m_merger_up->HasImporterForOrigin(from_context)) {
-      lldbassert(0 && "Couldn't find the importer for a source context!");
-      return nullptr;
-    }
-
-    if (llvm::Expected<Decl *> decl_or_error =
-            m_merger_up->ImporterForOrigin(from_context).Import(src_decl)) {
-      return *decl_or_error;
-    } else {
-      Log *log =
-          lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
-      LLDB_LOG_ERROR(log, decl_or_error.takeError(),
-                     "Couldn't import decl: {0}");
-      return nullptr;
-    }
   } else {
     lldbassert(0 && "No mechanism for copying a decl!");
     return nullptr;
@@ -1998,19 +1827,12 @@ clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
 ClangASTImporter::DeclOrigin ClangASTSource::GetDeclOrigin(const clang::Decl *decl) {
   if (m_ast_importer_sp) {
     return m_ast_importer_sp->GetDeclOrigin(decl);
-  } else if (m_merger_up) {
-    return ClangASTImporter::DeclOrigin(); // Implement this correctly in ExternalASTMerger
   } else {
     // this can happen early enough that no ExternalASTSource is installed.
     return ClangASTImporter::DeclOrigin();
   }
 }
 
-clang::ExternalASTMerger &ClangASTSource::GetMergerUnchecked() {
-  lldbassert(m_merger_up != nullptr);
-  return *m_merger_up;
-}
-
 CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
   ClangASTContext *src_ast =
       llvm::dyn_cast_or_null<ClangASTContext>(src_type.GetTypeSystem());
@@ -2024,10 +1846,6 @@ CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
   if (m_ast_importer_sp) {
     copied_qual_type = ClangUtil::GetQualType(
         m_ast_importer_sp->CopyType(*m_clang_ast_context, src_type));
-  } else if (m_merger_up) {
-    copied_qual_type =
-        CopyTypeWithMerger(*src_ast->getASTContext(), *m_merger_up,
-                 ClangUtil::GetQualType(src_type));
   } else {
     lldbassert(0 && "No mechanism for copying a type!");
     return CompilerType();

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index 9d9eb49f1cb9..0ae65e526e7e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -15,7 +15,6 @@
 #include "lldb/Symbol/ClangExternalASTSourceCommon.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Target.h"
-#include "clang/AST/ExternalASTMerger.h"
 #include "clang/Basic/IdentifierTable.h"
 
 #include "llvm/ADT/SmallSet.h"
@@ -340,24 +339,6 @@ class ClangASTSource : public ClangExternalASTSourceCommon,
   ///     A copy of the Decl in m_ast_context, or NULL if the copy failed.
   clang::Decl *CopyDecl(clang::Decl *src_decl);
 
-  /// Copies a single Type to the target of the given ExternalASTMerger.
-  ///
-  /// \param[in] src_context
-  ///     The ASTContext containing the type.
-  ///
-  /// \param[in] merger
-  ///     The merger to use.  This isn't just *m_merger_up because it might be
-  ///     the persistent AST context's merger.
-  ///
-  /// \param[in] type
-  ///     The type to copy.
-  ///
-  /// \return
-  ///     A copy of the Type in the merger's target context.
-	clang::QualType CopyTypeWithMerger(clang::ASTContext &src_context,
-                                     clang::ExternalASTMerger &merger,
-                                     clang::QualType type);
-
   /// Determined the origin of a single Decl, if it can be found.
   ///
   /// \param[in] decl
@@ -373,14 +354,6 @@ class ClangASTSource : public ClangExternalASTSourceCommon,
   ///     True if lookup succeeded; false otherwise.
   ClangASTImporter::DeclOrigin GetDeclOrigin(const clang::Decl *decl);
 
-  /// Returns m_merger_up.  Only call this if the target is configured to use
-  /// modern lookup,
-	clang::ExternalASTMerger &GetMergerUnchecked();
-
-  /// Returns true if there is a merger.  This only occurs if the target is
-  /// using modern lookup.
-  bool HasMerger() { return (bool)m_merger_up; }
-
 protected:
   bool FindObjCMethodDeclsWithOrigin(
       unsigned int current_id, NameSearchContext &context,
@@ -401,8 +374,6 @@ class ClangASTSource : public ClangExternalASTSourceCommon,
   clang::FileManager *m_file_manager;
   /// The target's AST importer.
   lldb::ClangASTImporterSP m_ast_importer_sp;
-  /// The ExternalASTMerger for this parse.
-  std::unique_ptr<clang::ExternalASTMerger> m_merger_up;
   std::set<const clang::Decl *> m_active_lexical_decls;
   std::set<const char *> m_active_lookups;
 };

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
index 90b715f37cba..85a10400a201 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
@@ -12,8 +12,6 @@
 #include "lldb/Core/ClangForward.h"
 #include "lldb/Symbol/DeclVendor.h"
 
-#include "clang/AST/ExternalASTMerger.h"
-
 namespace lldb_private {
 
 // A clang specialized extension to DeclVendor.
@@ -23,13 +21,6 @@ class ClangDeclVendor : public DeclVendor {
 
   virtual ~ClangDeclVendor() {}
 
-  /// Interface for ExternalASTMerger. Returns an ImporterSource allowing type
-  /// completion.
-  ///
-  /// \return
-  ///     An ImporterSource for this ClangDeclVendor.
-  virtual clang::ExternalASTMerger::ImporterSource GetImporterSource() = 0;
-
   uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
                      std::vector<CompilerDecl> &decls) override;
 

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 192e43a46061..3a6b7018e48f 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -173,31 +173,6 @@ ClangExpressionDeclMap::TargetInfo ClangExpressionDeclMap::GetTargetInfo() {
   return ret;
 }
 
-static clang::QualType ExportAllDeclaredTypes(
-    clang::ExternalASTMerger &parent_merger, clang::ExternalASTMerger &merger,
-    clang::ASTContext &source, clang::FileManager &source_file_manager,
-    const clang::ExternalASTMerger::OriginMap &source_origin_map,
-    clang::FileID file, clang::QualType root) {
-  // Mark the source as temporary to make sure all declarations from the
-  // AST are exported. Also add the parent_merger as the merger into the
-  // source AST so that the merger can track back any declarations from
-  // the persistent ASTs we used as sources.
-  clang::ExternalASTMerger::ImporterSource importer_source(
-      source, source_file_manager, source_origin_map, /*Temporary*/ true,
-      &parent_merger);
-  merger.AddSources(importer_source);
-  clang::ASTImporter &exporter = merger.ImporterForOrigin(source);
-  llvm::Expected<clang::QualType> ret_or_error = exporter.Import(root);
-  merger.RemoveSources(importer_source);
-  if (ret_or_error) {
-    return *ret_or_error;
-  } else {
-    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
-    LLDB_LOG_ERROR(log, ret_or_error.takeError(), "Couldn't import type: {0}");
-    return clang::QualType();
-  }
-}
-
 TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
                                                 ClangASTContext &source,
                                                 TypeFromParser parser_type) {
@@ -207,18 +182,6 @@ TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
 
   if (m_ast_importer_sp) {
     return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
-  } else if (m_merger_up) {
-    clang::FileID source_file =
-        source.getASTContext()->getSourceManager().getFileID(
-            source.getASTContext()->getTranslationUnitDecl()->getLocation());
-    auto scratch_ast_context = static_cast<ClangASTContextForExpressions *>(
-        ClangASTContext::GetScratch(*m_target));
-    clang::QualType exported_type = ExportAllDeclaredTypes(
-        *m_merger_up.get(), scratch_ast_context->GetMergerUnchecked(),
-        *source.getASTContext(), *source.getFileManager(),
-        m_merger_up->GetOrigins(), source_file,
-        clang::QualType::getFromOpaquePtr(parser_type.GetOpaqueQualType()));
-    return TypeFromUser(exported_type.getAsOpaquePtr(), &target);
   } else {
     lldbassert(0 && "No mechanism for deporting a type!");
     return TypeFromUser();

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index f3bb24ee79da..ff0905dda4ef 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -84,8 +84,6 @@ class ClangModulesDeclVendorImpl : public ClangModulesDeclVendor {
 
   void ForEachMacro(const ModuleVector &modules,
                     std::function<bool(const std::string &)> handler) override;
-
-  clang::ExternalASTMerger::ImporterSource GetImporterSource() override;
 private:
   void
   ReportModuleExportsHelper(std::set<ClangModulesDeclVendor::ModuleID> &exports,
@@ -110,7 +108,6 @@ class ClangModulesDeclVendorImpl : public ClangModulesDeclVendor {
   typedef std::set<ModuleID> ImportedModuleSet;
   ImportedModuleMap m_imported_modules;
   ImportedModuleSet m_user_imported_modules;
-  const clang::ExternalASTMerger::OriginMap m_origin_map;
   // We assume that every ASTContext has an ClangASTContext, so we also store
   // a custom ClangASTContext for our internal ASTContext.
   std::unique_ptr<ClangASTContext> m_ast_context;
@@ -160,7 +157,7 @@ ClangModulesDeclVendorImpl::ClangModulesDeclVendorImpl(
     : m_diagnostics_engine(std::move(diagnostics_engine)),
       m_compiler_invocation(std::move(compiler_invocation)),
       m_compiler_instance(std::move(compiler_instance)),
-      m_parser(std::move(parser)), m_origin_map() {
+      m_parser(std::move(parser)) {
 
   // Initialize our ClangASTContext.
   m_ast_context.reset(new ClangASTContext(m_compiler_instance->getASTContext()));
@@ -569,13 +566,6 @@ ClangModulesDeclVendorImpl::DoGetModule(clang::ModuleIdPath path,
                                          is_inclusion_directive);
 }
 
-clang::ExternalASTMerger::ImporterSource
-ClangModulesDeclVendorImpl::GetImporterSource() {
-  return clang::ExternalASTMerger::ImporterSource(
-      m_compiler_instance->getASTContext(),
-      m_compiler_instance->getFileManager(), m_origin_map);
-}
-
 static const char *ModuleImportBufferName = "LLDBModulesMemoryBuffer";
 
 lldb_private::ClangModulesDeclVendor *

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index 435392023001..6acd6a6df6b7 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -639,10 +639,3 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
 
   return ret;
 }
-
-clang::ExternalASTMerger::ImporterSource
-AppleObjCDeclVendor::GetImporterSource() {
-  return clang::ExternalASTMerger::ImporterSource(*m_ast_ctx.getASTContext(),
-                                                  *m_ast_ctx.getFileManager(),
-                                                  m_ast_ctx.GetOriginMap());
-}

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
index 99ca4b748709..311113a27735 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
@@ -30,8 +30,6 @@ class AppleObjCDeclVendor : public ClangDeclVendor {
   uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
                      std::vector<clang::NamedDecl *> &decls) override;
 
-  clang::ExternalASTMerger::ImporterSource GetImporterSource() override;
-
   friend class AppleObjCExternalASTSource;
 
 private:

diff  --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 3b6b0db34499..efc7b4d780e7 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -9517,9 +9517,3 @@ PersistentExpressionState *
 ClangASTContextForExpressions::GetPersistentExpressionState() {
   return m_persistent_variables.get();
 }
-
-clang::ExternalASTMerger &
-ClangASTContextForExpressions::GetMergerUnchecked() {
-  lldbassert(m_scratch_ast_source_up != nullptr);
-  return m_scratch_ast_source_up->GetMergerUnchecked();
-}

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index dbbfb5368d4a..83dc3de3ce56 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -3545,18 +3545,6 @@ void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
                                             true);
 }
 
-bool TargetProperties::GetUseModernTypeLookup() const {
-  const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
-      nullptr, false, ePropertyExperimental);
-  OptionValueProperties *exp_values =
-      exp_property->GetValue()->GetAsProperties();
-  if (exp_values)
-    return exp_values->GetPropertyAtIndexAsBoolean(
-        nullptr, ePropertyUseModernTypeLookup, true);
-  else
-    return true;
-}
-
 ArchSpec TargetProperties::GetDefaultArchitecture() const {
   OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(
       nullptr, ePropertyDefaultArch);

diff  --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td
index 9079c3cf4276..ff8062aaa2cb 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -4,9 +4,6 @@ let Definition = "experimental" in {
   def InjectLocalVars : Property<"inject-local-vars", "Boolean">,
     Global, DefaultTrue,
     Desc<"If true, inject local variables explicitly into the expression text. This will fix symbol resolution when there are name collisions between ivars and local variables. But it can make expressions run much more slowly.">;
-  def UseModernTypeLookup : Property<"use-modern-type-lookup", "Boolean">,
-    Global, DefaultFalse,
-    Desc<"If true, use Clang's modern type lookup infrastructure.">;
 }
 
 let Definition = "target" in {


        


More information about the lldb-commits mailing list