Skip to content

Commit 47f25ae

Browse files
committed
Split DWARFImporterDelegate into two parts. NFC
1. SwiftDWARFImporterForClangTypes is owned by a TypeSystemSwiftTypeRef. It imports Clang types from DWARF. 2. SwiftDWARFImporterDelegate is a swift::DWARFImporterDelegate that uses clang::ASTImporter to import a type from the TypeSystemClang used by the DWARFParser into the clang ASTContext used by one SwiftASTContext's ClangImporter. This is in preparation for creating more flexible SwiftASTContexts in the future.
1 parent 3361426 commit 47f25ae

File tree

8 files changed

+367
-304
lines changed

8 files changed

+367
-304
lines changed

lldb/source/Plugins/TypeSystem/Swift/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_lldb_library(lldbPluginTypeSystemSwift PLUGIN
2-
DWARFImporterDelegate.cpp
2+
SwiftDWARFImporterForClangTypes.cpp
33
TypeSystemSwift.cpp
44
TypeSystemSwiftTypeRef.cpp
55
SwiftASTContext.cpp

lldb/source/Plugins/TypeSystem/Swift/DWARFImporterDelegate.cpp

Lines changed: 0 additions & 287 deletions
This file was deleted.

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "Plugins/TypeSystem/Swift/SwiftASTContext.h"
14+
#include "Plugins/TypeSystem/Swift/SwiftDWARFImporterForClangTypes.h"
1415
#include "Plugins/TypeSystem/Swift/StoringDiagnosticConsumer.h"
1516
#include "Plugins/ExpressionParser/Swift/SwiftPersistentExpressionState.h"
1617

@@ -2939,12 +2940,13 @@ swift::ASTContext *SwiftASTContext::GetASTContext() {
29392940
if (!clang_importer_options.OverrideResourceDir.empty()) {
29402941
// Create the DWARFImporterDelegate.
29412942
const auto &props = ModuleList::GetGlobalModuleListProperties();
2942-
swift::DWARFImporterDelegate *delegate = nullptr;
29432943
if (props.GetUseSwiftDWARFImporter())
2944-
delegate = &m_typeref_typesystem->GetDWARFImporterDelegate();
2944+
m_dwarfimporter_delegate_up =
2945+
std::make_unique<SwiftDWARFImporterDelegate>(*this);
29452946
auto importer_diags = getScopedDiagnosticConsumer();
29462947
clang_importer_ap = swift::ClangImporter::create(
2947-
*m_ast_context_ap, "", m_dependency_tracker.get(), delegate);
2948+
*m_ast_context_ap, "", m_dependency_tracker.get(),
2949+
m_dwarfimporter_delegate_up.get());
29482950

29492951
// Handle any errors.
29502952
if (!clang_importer_ap || importer_diags->HasErrors()) {

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ namespace lldb_private {
8484
struct SourceModule;
8585
class SwiftASTContext;
8686
class ClangExternalASTSourceCallbacks;
87-
8887
CompilerType ToCompilerType(swift::Type qual_type);
8988

9089
namespace detail {
@@ -904,6 +903,7 @@ class SwiftASTContext : public TypeSystemSwift {
904903
swift::ClangImporter *m_clangimporter = nullptr;
905904
/// Wraps the clang::ASTContext owned by ClangImporter.
906905
std::shared_ptr<TypeSystemClang> m_clangimporter_typesystem;
906+
std::unique_ptr<swift::DWARFImporterDelegate> m_dwarfimporter_delegate_up;
907907
SwiftModuleMap m_swift_module_cache;
908908
SwiftTypeFromMangledNameMap m_mangled_name_to_type_map;
909909
SwiftMangledNameFromTypeMap m_type_to_mangled_name_map;

0 commit comments

Comments
 (0)