[lldb] Move clang-based files out of Symbol
Summary:
This change represents the move of ClangASTImporter, ClangASTMetadata,
ClangExternalASTSourceCallbacks, ClangUtil, CxxModuleHandler, and
TypeSystemClang from lldbSource to lldbPluginExpressionParserClang.h
This explicitly removes knowledge of clang internals from lldbSymbol,
moving towards a more generic core implementation of lldb.
Reviewers: JDevlieghere, davide, aprantl, teemperor, clayborg, labath, jingham, shafik
Subscribers: emaste, mgorny, arphaman, jfb, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73661
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index 9d566b5..d518c57 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -22,7 +22,6 @@
#include "lldb/Host/Host.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Utility/Timer.h"
#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
@@ -96,6 +95,7 @@
#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
#include "Plugins/SymbolVendor/wasm/SymbolVendorWasm.h"
#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index 0680a76..16e5498 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "Utility/PPC64LE_DWARF_Registers.h"
#include "Utility/PPC64_DWARF_Registers.h"
#include "lldb/Core/Module.h"
@@ -19,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Core/ValueObjectRegister.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt b/lldb/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
index b31182d..0a0bb7b 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
@@ -5,6 +5,7 @@
lldbCore
lldbSymbol
lldbTarget
+ lldbPluginTypeSystemClang
LINK_COMPONENTS
Support
)
diff --git a/lldb/source/Plugins/CMakeLists.txt b/lldb/source/Plugins/CMakeLists.txt
index 5092b21..08817ba 100644
--- a/lldb/source/Plugins/CMakeLists.txt
+++ b/lldb/source/Plugins/CMakeLists.txt
@@ -19,4 +19,5 @@
add_subdirectory(SymbolFile)
add_subdirectory(SystemRuntime)
add_subdirectory(SymbolVendor)
+add_subdirectory(TypeSystem)
add_subdirectory(UnwindAssembly)
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
index 515c82d..c470bc6 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
@@ -11,6 +11,7 @@
lldbSymbol
lldbTarget
lldbUtility
+ lldbPluginTypeSystemClang
LINK_COMPONENTS
Support
)
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 20c60a4..324a0d0 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -16,7 +16,6 @@
#include "lldb/Core/Section.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Host/FileSystem.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ABI.h"
@@ -32,6 +31,7 @@
#include "lldb/Utility/State.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
//#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN
#ifdef ENABLE_DEBUG_PRINTF
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index a9e674e..7bc1406 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -11,7 +11,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/ABI.h"
@@ -24,6 +23,8 @@
#include "DynamicLoaderDarwin.h"
#include "DynamicLoaderMacOS.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
using namespace lldb;
using namespace lldb_private;
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index ce0132d..c3f3643 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -12,7 +12,6 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ABI.h"
@@ -30,6 +29,7 @@
#include "DynamicLoaderMacOSXDYLD.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
//#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN
#ifdef ENABLE_DEBUG_PRINTF
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index 7b2acb4..f0e1b5d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -8,10 +8,10 @@
#include "ASTResultSynthesizer.h"
+#include "ClangASTImporter.h"
#include "ClangPersistentVariables.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
index e92d089..3bb120a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -6,19 +6,24 @@
ASTResultSynthesizer.cpp
ASTStructExtractor.cpp
ASTUtils.cpp
+ ClangASTImporter.cpp
+ ClangASTMetadata.cpp
ClangASTSource.cpp
ClangDeclVendor.cpp
ClangExpressionDeclMap.cpp
ClangExpressionParser.cpp
ClangExpressionSourceCode.cpp
ClangExpressionVariable.cpp
+ ClangExternalASTSourceCallbacks.cpp
ClangFunctionCaller.cpp
ClangHost.cpp
ClangModulesDeclVendor.cpp
ClangPersistentVariables.cpp
ClangUserExpression.cpp
+ ClangUtil.cpp
ClangUtilityFunction.cpp
CppModuleConfiguration.cpp
+ CxxModuleHandler.cpp
IRForTarget.cpp
IRDynamicChecks.cpp
@@ -35,6 +40,8 @@
lldbUtility
lldbPluginCPlusPlusLanguage
lldbPluginCPPRuntime
+ lldbPluginObjCRuntime
+ lldbPluginTypeSystemClang
CLANG_LIBS
clangAST
clangCodeGen
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
similarity index 98%
rename from lldb/source/Symbol/ClangASTImporter.cpp
rename to lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 10e9868..479cb64 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -6,11 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
#include "clang/AST/Decl.h"
@@ -20,6 +16,11 @@
#include "clang/Sema/Sema.h"
#include "llvm/Support/raw_ostream.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
#include <memory>
using namespace lldb_private;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
new file mode 100644
index 0000000..b05a89c
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -0,0 +1,327 @@
+//===-- ClangASTImporter.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ClangASTImporter_h_
+#define liblldb_ClangASTImporter_h_
+
+#include <map>
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "clang/AST/ASTImporter.h"
+#include "clang/AST/CharUnits.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
+#include "lldb/lldb-types.h"
+
+#include "Plugins/ExpressionParser/Clang/CxxModuleHandler.h"
+
+#include "llvm/ADT/DenseMap.h"
+
+namespace lldb_private {
+
+class ClangASTImporter {
+public:
+ struct LayoutInfo {
+ LayoutInfo() = default;
+ typedef llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ OffsetMap;
+
+ uint64_t bit_size = 0;
+ uint64_t alignment = 0;
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets;
+ OffsetMap base_offsets;
+ OffsetMap vbase_offsets;
+ };
+
+ ClangASTImporter()
+ : m_file_manager(clang::FileSystemOptions(),
+ FileSystem::Instance().GetVirtualFileSystem()) {}
+
+ CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type);
+
+ clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
+
+ CompilerType DeportType(TypeSystemClang &dst, const CompilerType &src_type);
+
+ clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
+
+ /// Sets the layout for the given RecordDecl. The layout will later be
+ /// used by Clang's during code generation. Not calling this function for
+ /// a RecordDecl will cause that Clang's codegen tries to layout the
+ /// record by itself.
+ ///
+ /// \param decl The RecordDecl to set the layout for.
+ /// \param layout The layout for the record.
+ void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout);
+
+ bool LayoutRecordType(
+ const clang::RecordDecl *record_decl, uint64_t &bit_size,
+ uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &vbase_offsets);
+
+ bool CanImport(const CompilerType &type);
+
+ bool Import(const CompilerType &type);
+
+ bool CompleteType(const CompilerType &compiler_type);
+
+ bool CompleteTagDecl(clang::TagDecl *decl);
+
+ bool CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl *origin);
+
+ bool CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *interface_decl);
+
+ bool CompleteAndFetchChildren(clang::QualType type);
+
+ bool RequireCompleteType(clang::QualType type);
+
+ void SetDeclOrigin(const clang::Decl *decl, clang::Decl *original_decl);
+
+ ClangASTMetadata *GetDeclMetadata(const clang::Decl *decl);
+
+ //
+ // Namespace maps
+ //
+
+ typedef std::vector<std::pair<lldb::ModuleSP, CompilerDeclContext>>
+ NamespaceMap;
+ typedef std::shared_ptr<NamespaceMap> NamespaceMapSP;
+
+ void RegisterNamespaceMap(const clang::NamespaceDecl *decl,
+ NamespaceMapSP &namespace_map);
+
+ NamespaceMapSP GetNamespaceMap(const clang::NamespaceDecl *decl);
+
+ void BuildNamespaceMap(const clang::NamespaceDecl *decl);
+
+ //
+ // Completers for maps
+ //
+
+ class MapCompleter {
+ public:
+ virtual ~MapCompleter();
+
+ virtual void CompleteNamespaceMap(NamespaceMapSP &namespace_map,
+ ConstString name,
+ NamespaceMapSP &parent_map) const = 0;
+ };
+
+ void InstallMapCompleter(clang::ASTContext *dst_ctx,
+ MapCompleter &completer) {
+ ASTContextMetadataSP context_md;
+ ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
+
+ if (context_md_iter == m_metadata_map.end()) {
+ context_md = ASTContextMetadataSP(new ASTContextMetadata(dst_ctx));
+ m_metadata_map[dst_ctx] = context_md;
+ } else {
+ context_md = context_md_iter->second;
+ }
+
+ context_md->m_map_completer = &completer;
+ }
+
+ void ForgetDestination(clang::ASTContext *dst_ctx);
+ void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx);
+
+public:
+ struct DeclOrigin {
+ DeclOrigin() : ctx(nullptr), decl(nullptr) {}
+
+ DeclOrigin(clang::ASTContext *_ctx, clang::Decl *_decl)
+ : ctx(_ctx), decl(_decl) {}
+
+ DeclOrigin(const DeclOrigin &rhs) {
+ ctx = rhs.ctx;
+ decl = rhs.decl;
+ }
+
+ void operator=(const DeclOrigin &rhs) {
+ ctx = rhs.ctx;
+ decl = rhs.decl;
+ }
+
+ bool Valid() { return (ctx != nullptr || decl != nullptr); }
+
+ clang::ASTContext *ctx;
+ clang::Decl *decl;
+ };
+
+ typedef llvm::DenseMap<const clang::Decl *, DeclOrigin> OriginMap;
+
+ /// Listener interface used by the ASTImporterDelegate to inform other code
+ /// about decls that have been imported the first time.
+ struct NewDeclListener {
+ virtual ~NewDeclListener() = default;
+ /// A decl has been imported for the first time.
+ virtual void NewDeclImported(clang::Decl *from, clang::Decl *to) = 0;
+ };
+
+ /// ASTImporter that intercepts and records the import process of the
+ /// underlying ASTImporter.
+ ///
+ /// This class updates the map from declarations to their original
+ /// declarations and can record declarations that have been imported in a
+ /// certain interval.
+ ///
+ /// When intercepting a declaration import, the ASTImporterDelegate uses the
+ /// CxxModuleHandler to replace any missing or malformed declarations with
+ /// their counterpart from a C++ module.
+ struct ASTImporterDelegate : public clang::ASTImporter {
+ ASTImporterDelegate(ClangASTImporter &master, clang::ASTContext *target_ctx,
+ clang::ASTContext *source_ctx)
+ : clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx,
+ master.m_file_manager, true /*minimal*/),
+ m_master(master), m_source_ctx(source_ctx) {
+ setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
+ }
+
+ /// Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate
+ /// and deattaches it at the end of the scope. Supports being used multiple
+ /// times on the same ASTImporterDelegate instance in nested scopes.
+ class CxxModuleScope {
+ /// The handler we attach to the ASTImporterDelegate.
+ CxxModuleHandler m_handler;
+ /// The ASTImporterDelegate we are supposed to attach the handler to.
+ ASTImporterDelegate &m_delegate;
+ /// True iff we attached the handler to the ASTImporterDelegate.
+ bool m_valid = false;
+
+ public:
+ CxxModuleScope(ASTImporterDelegate &delegate, clang::ASTContext *dst_ctx)
+ : m_delegate(delegate) {
+ // If the delegate doesn't have a CxxModuleHandler yet, create one
+ // and attach it.
+ if (!delegate.m_std_handler) {
+ m_handler = CxxModuleHandler(delegate, dst_ctx);
+ m_valid = true;
+ delegate.m_std_handler = &m_handler;
+ }
+ }
+ ~CxxModuleScope() {
+ if (m_valid) {
+ // Make sure no one messed with the handler we placed.
+ assert(m_delegate.m_std_handler == &m_handler);
+ m_delegate.m_std_handler = nullptr;
+ }
+ }
+ };
+
+ void ImportDefinitionTo(clang::Decl *to, clang::Decl *from);
+
+ void Imported(clang::Decl *from, clang::Decl *to) override;
+
+ clang::Decl *GetOriginalDecl(clang::Decl *To) override;
+
+ void SetImportListener(NewDeclListener *listener) {
+ assert(m_new_decl_listener == nullptr && "Already attached a listener?");
+ m_new_decl_listener = listener;
+ }
+ void RemoveImportListener() { m_new_decl_listener = nullptr; }
+
+ protected:
+ llvm::Expected<clang::Decl *> ImportImpl(clang::Decl *From) override;
+
+ private:
+ /// Decls we should ignore when mapping decls back to their original
+ /// ASTContext. Used by the CxxModuleHandler to mark declarations that
+ /// were created from the 'std' C++ module to prevent that the Importer
+ /// tries to sync them with the broken equivalent in the debug info AST.
+ llvm::SmallPtrSet<clang::Decl *, 16> m_decls_to_ignore;
+ ClangASTImporter &m_master;
+ clang::ASTContext *m_source_ctx;
+ CxxModuleHandler *m_std_handler = nullptr;
+ /// The currently attached listener.
+ NewDeclListener *m_new_decl_listener = nullptr;
+ };
+
+ typedef std::shared_ptr<ASTImporterDelegate> ImporterDelegateSP;
+ typedef llvm::DenseMap<clang::ASTContext *, ImporterDelegateSP> DelegateMap;
+ typedef llvm::DenseMap<const clang::NamespaceDecl *, NamespaceMapSP>
+ NamespaceMetaMap;
+
+ struct ASTContextMetadata {
+ ASTContextMetadata(clang::ASTContext *dst_ctx)
+ : m_dst_ctx(dst_ctx), m_delegates(), m_origins(), m_namespace_maps(),
+ m_map_completer(nullptr) {}
+
+ clang::ASTContext *m_dst_ctx;
+ DelegateMap m_delegates;
+ OriginMap m_origins;
+
+ NamespaceMetaMap m_namespace_maps;
+ MapCompleter *m_map_completer;
+ };
+
+ typedef std::shared_ptr<ASTContextMetadata> ASTContextMetadataSP;
+ typedef llvm::DenseMap<const clang::ASTContext *, ASTContextMetadataSP>
+ ContextMetadataMap;
+
+ ContextMetadataMap m_metadata_map;
+
+ ASTContextMetadataSP GetContextMetadata(clang::ASTContext *dst_ctx) {
+ ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
+
+ if (context_md_iter == m_metadata_map.end()) {
+ ASTContextMetadataSP context_md =
+ ASTContextMetadataSP(new ASTContextMetadata(dst_ctx));
+ m_metadata_map[dst_ctx] = context_md;
+ return context_md;
+ }
+ return context_md_iter->second;
+ }
+
+ ASTContextMetadataSP MaybeGetContextMetadata(clang::ASTContext *dst_ctx) {
+ ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
+
+ if (context_md_iter != m_metadata_map.end())
+ return context_md_iter->second;
+ return ASTContextMetadataSP();
+ }
+
+ ImporterDelegateSP GetDelegate(clang::ASTContext *dst_ctx,
+ clang::ASTContext *src_ctx) {
+ ASTContextMetadataSP context_md = GetContextMetadata(dst_ctx);
+
+ DelegateMap &delegates = context_md->m_delegates;
+ DelegateMap::iterator delegate_iter = delegates.find(src_ctx);
+
+ if (delegate_iter == delegates.end()) {
+ ImporterDelegateSP delegate =
+ ImporterDelegateSP(new ASTImporterDelegate(*this, dst_ctx, src_ctx));
+ delegates[src_ctx] = delegate;
+ return delegate;
+ }
+ return delegate_iter->second;
+ }
+
+public:
+ DeclOrigin GetDeclOrigin(const clang::Decl *decl);
+
+ clang::FileManager m_file_manager;
+ typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo>
+ RecordDeclToLayoutMap;
+
+ RecordDeclToLayoutMap m_record_decl_to_layout_map;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ClangASTImporter_h_
diff --git a/lldb/source/Symbol/ClangASTMetadata.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
similarity index 93%
rename from lldb/source/Symbol/ClangASTMetadata.cpp
rename to lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
index 0c894e0..42933c7 100644
--- a/lldb/source/Symbol/ClangASTMetadata.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
#include "lldb/Utility/Stream.h"
using namespace lldb_private;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h
new file mode 100644
index 0000000..fdf4388
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h
@@ -0,0 +1,100 @@
+//===-- ClangASTMetadata.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ClangASTMetadata_h
+#define liblldb_ClangASTMetadata_h
+
+#include "lldb/Core/dwarf.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h"
+
+namespace lldb_private {
+
+class ClangASTMetadata {
+public:
+ ClangASTMetadata()
+ : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false),
+ m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true) {}
+
+ bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; }
+
+ void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; }
+
+ void SetUserID(lldb::user_id_t user_id) {
+ m_user_id = user_id;
+ m_union_is_user_id = true;
+ m_union_is_isa_ptr = false;
+ }
+
+ lldb::user_id_t GetUserID() const {
+ if (m_union_is_user_id)
+ return m_user_id;
+ else
+ return LLDB_INVALID_UID;
+ }
+
+ void SetISAPtr(uint64_t isa_ptr) {
+ m_isa_ptr = isa_ptr;
+ m_union_is_user_id = false;
+ m_union_is_isa_ptr = true;
+ }
+
+ uint64_t GetISAPtr() const {
+ if (m_union_is_isa_ptr)
+ return m_isa_ptr;
+ else
+ return 0;
+ }
+
+ void SetObjectPtrName(const char *name) {
+ m_has_object_ptr = true;
+ if (strcmp(name, "self") == 0)
+ m_is_self = true;
+ else if (strcmp(name, "this") == 0)
+ m_is_self = false;
+ else
+ m_has_object_ptr = false;
+ }
+
+ lldb::LanguageType GetObjectPtrLanguage() const {
+ if (m_has_object_ptr) {
+ if (m_is_self)
+ return lldb::eLanguageTypeObjC;
+ else
+ return lldb::eLanguageTypeC_plus_plus;
+ }
+ return lldb::eLanguageTypeUnknown;
+ }
+
+ const char *GetObjectPtrName() const {
+ if (m_has_object_ptr) {
+ if (m_is_self)
+ return "self";
+ else
+ return "this";
+ } else
+ return nullptr;
+ }
+
+ bool HasObjectPtr() const { return m_has_object_ptr; }
+
+ void Dump(Stream *s);
+
+private:
+ union {
+ lldb::user_id_t m_user_id;
+ uint64_t m_isa_ptr;
+ };
+
+ bool m_union_is_user_id : 1, m_union_is_isa_ptr : 1, m_has_object_ptr : 1,
+ m_is_self : 1, m_is_dynamic_cxx : 1;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ClangASTMetadata_h
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 8fb0f40..7362a00 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -13,8 +13,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolFile.h"
@@ -24,7 +22,9 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include <memory>
#include <vector>
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index 2b711db..aeb06b3 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -11,7 +11,7 @@
#include <set>
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
#include "clang/AST/ExternalASTSource.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
index f5b0c21..867d4ff 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Utility/ConstString.h"
using namespace lldb_private;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 8f4c92e..58094e0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -11,15 +11,15 @@
#include "ClangASTSource.h"
#include "ClangModulesDeclVendor.h"
#include "ClangPersistentVariables.h"
+#include "ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/Materializer.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index eeab419..1516d5b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -67,6 +67,7 @@
#include "IRForTarget.h"
#include "ModuleDependencyCollector.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
@@ -75,7 +76,6 @@
#include "lldb/Expression/IRInterpreter.h"
#include "lldb/Host/File.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
diff --git a/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
similarity index 92%
rename from lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp
rename to lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
index 4aa1755..26dc4d6 100644
--- a/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
-#include "lldb/Symbol/TypeSystemClang.h"
+#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "clang/AST/Decl.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
new file mode 100644
index 0000000..98e9f5a
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
@@ -0,0 +1,46 @@
+//===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ClangExternalASTSourceCallbacks_h_
+#define liblldb_ClangExternalASTSourceCallbacks_h_
+
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "clang/AST/ExternalASTSource.h"
+
+namespace lldb_private {
+
+class TypeSystemClang;
+
+class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
+public:
+ ClangExternalASTSourceCallbacks(TypeSystemClang &ast) : m_ast(ast) {}
+
+ void FindExternalLexicalDecls(
+ const clang::DeclContext *DC,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+ llvm::SmallVectorImpl<clang::Decl *> &Result) override;
+
+ void CompleteType(clang::TagDecl *tag_decl) override;
+
+ void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override;
+
+ bool layoutRecordType(
+ const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &BaseOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &VirtualBaseOffsets) override;
+
+private:
+ TypeSystemClang &m_ast;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ClangExternalASTSourceCallbacks_h_
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
index d2a379e..ea56e42 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -21,12 +21,12 @@
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/IR/Module.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index cc3b4ed..4b0521a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -24,10 +24,10 @@
#include "ClangModulesDeclVendor.h"
#include "ModuleDependencyCollector.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/SourceModule.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index f847dc9..da26c6a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "ClangPersistentVariables.h"
+#include "ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Value.h"
-#include "lldb/Symbol/ClangASTImporter.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 2fca504..492ab15 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -20,6 +20,7 @@
#include "ClangUserExpression.h"
#include "ASTResultSynthesizer.h"
+#include "ClangASTMetadata.h"
#include "ClangDiagnostic.h"
#include "ClangExpressionDeclMap.h"
#include "ClangExpressionParser.h"
@@ -27,6 +28,7 @@
#include "ClangPersistentVariables.h"
#include "CppModuleConfiguration.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
@@ -37,8 +39,6 @@
#include "lldb/Expression/Materializer.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
diff --git a/lldb/source/Symbol/ClangUtil.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
similarity index 95%
rename from lldb/source/Symbol/ClangUtil.cpp
rename to lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
index 2f3307e..a7f5dce 100644
--- a/lldb/source/Symbol/ClangUtil.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
@@ -8,8 +8,8 @@
// types and decls.
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangUtil.h"
-#include "lldb/Symbol/TypeSystemClang.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace clang;
using namespace lldb_private;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h
new file mode 100644
index 0000000..31e86ca
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h
@@ -0,0 +1,50 @@
+//===-- ClangUtil.h ---------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+// A collection of helper methods and data structures for manipulating clang
+// types and decls.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SYMBOL_CLANGUTIL_H
+#define LLDB_SYMBOL_CLANGUTIL_H
+
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Type.h"
+
+#include "lldb/Symbol/CompilerType.h"
+
+namespace clang {
+class TagDecl;
+}
+
+namespace lldb_private {
+struct ClangUtil {
+ static bool IsClangType(const CompilerType &ct);
+
+ /// Returns the clang::Decl of the given CompilerDecl.
+ /// CompilerDecl has to be valid and represent a clang::Decl.
+ static clang::Decl *GetDecl(const CompilerDecl &decl);
+
+ static clang::QualType GetQualType(const CompilerType &ct);
+
+ static clang::QualType GetCanonicalQualType(const CompilerType &ct);
+
+ static CompilerType RemoveFastQualifiers(const CompilerType &ct);
+
+ static clang::TagDecl *GetAsTagDecl(const CompilerType &type);
+
+ /// Returns a textual representation of the given Decl's AST. Does not
+ /// deserialize any child nodes.
+ static std::string DumpDecl(const clang::Decl *d);
+ /// Returns a textual representation of the given type.
+ static std::string ToString(const clang::Type *t);
+ /// Returns a textual representation of the given CompilerType (assuming
+ /// its underlying type is a Clang type).
+ static std::string ToString(const CompilerType &c);
+};
+}
+
+#endif
diff --git a/lldb/source/Symbol/CxxModuleHandler.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
similarity index 98%
rename from lldb/source/Symbol/CxxModuleHandler.cpp
rename to lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index 4d9af81..ae2f074 100644
--- a/lldb/source/Symbol/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/CxxModuleHandler.h"
+#include "Plugins/ExpressionParser/Clang/CxxModuleHandler.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Utility/Log.h"
#include "clang/Sema/Lookup.h"
#include "llvm/Support/Error.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h
new file mode 100644
index 0000000..f4aef36
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h
@@ -0,0 +1,65 @@
+//===-- CxxModuleHandler.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_CxxModuleHandler_h_
+#define liblldb_CxxModuleHandler_h_
+
+#include "clang/AST/ASTImporter.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/ADT/StringSet.h"
+
+namespace lldb_private {
+
+/// Handles importing decls into an ASTContext with an attached C++ module.
+///
+/// This class searches a C++ module (which must be attached to the target
+/// ASTContext) for an equivalent decl to the one that should be imported.
+/// If the decl that is found in the module is a suitable replacement
+/// for the decl that should be imported, the module decl will be treated as
+/// the result of the import process.
+///
+/// If the Decl that should be imported is a template specialization
+/// that doesn't exist yet in the target ASTContext (e.g. `std::vector<int>`),
+/// then this class tries to create the template specialization in the target
+/// ASTContext. This is only possible if the CxxModuleHandler can determine
+/// that instantiating this template is safe to do, e.g. because the target
+/// decl is a container class from the STL.
+class CxxModuleHandler {
+ /// The ASTImporter that should be used to import any Decls which aren't
+ /// directly handled by this class itself.
+ clang::ASTImporter *m_importer = nullptr;
+
+ /// The Sema instance of the target ASTContext.
+ clang::Sema *m_sema = nullptr;
+
+ /// List of template names this class currently supports. These are the
+ /// template names inside the 'std' namespace such as 'vector' or 'list'.
+ llvm::StringSet<> m_supported_templates;
+
+ /// Tries to manually instantiate the given foreign template in the target
+ /// context (designated by m_sema).
+ llvm::Optional<clang::Decl *> tryInstantiateStdTemplate(clang::Decl *d);
+
+public:
+ CxxModuleHandler() = default;
+ CxxModuleHandler(clang::ASTImporter &importer, clang::ASTContext *target);
+
+ /// Attempts to import the given decl into the target ASTContext by
+ /// deserializing it from the 'std' module. This function returns a Decl if a
+ /// Decl has been deserialized from the 'std' module. Otherwise this function
+ /// returns nothing.
+ llvm::Optional<clang::Decl *> Import(clang::Decl *d);
+
+ /// Returns true iff this instance is capable of importing any declarations
+ /// in the target ASTContext.
+ bool isValid() const { return m_sema != nullptr; }
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CxxModuleHandler_h_
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index bcf13e5..e70ab1c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -9,7 +9,9 @@
#include "IRForTarget.h"
#include "ClangExpressionDeclMap.h"
+#include "ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InstrTypes.h"
@@ -27,8 +29,6 @@
#include "lldb/Core/dwarf.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataBufferHeap.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 43b2cad..e5f19a6 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -8,13 +8,13 @@
#include "BlockPointer.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index ea36c7e..2a541a9 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -29,6 +29,7 @@
lldbUtility
lldbPluginClangCommon
lldbPluginCPPRuntime
+ lldbPluginTypeSystemClang
LINK_COMPONENTS
Support
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 4f0e061..41bbd2b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -10,13 +10,13 @@
#include "llvm/Support/ConvertUTF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Time.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 240821a..b2b68b2 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -17,7 +17,6 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
@@ -27,6 +26,7 @@
#include "lldb/Utility/Stream.h"
#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
index b60e529..6de4637 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Target.h"
using namespace lldb;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index 3f607c6..4c5940a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 4443295..64a199e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 2091c0b..3a44197 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 75c9239..78f5875 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -8,11 +8,11 @@
#include "LibStdcpp.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
diff --git a/lldb/source/Plugins/Language/ObjC/CF.cpp b/lldb/source/Plugins/Language/ObjC/CF.cpp
index 0ee2a73..9e4eb9d 100644
--- a/lldb/source/Plugins/Language/ObjC/CF.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CF.cpp
@@ -8,10 +8,10 @@
#include "CF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/Language/ObjC/CMakeLists.txt b/lldb/source/Plugins/Language/ObjC/CMakeLists.txt
index ebb96c2..7b220e4 100644
--- a/lldb/source/Plugins/Language/ObjC/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/ObjC/CMakeLists.txt
@@ -31,6 +31,7 @@
lldbUtility
lldbPluginAppleObjCRuntime
lldbPluginClangCommon
+ lldbPluginTypeSystemClang
CLANG_LIBS
clangAST
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 67e11ae..8a44811 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -8,6 +8,7 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
@@ -15,7 +16,6 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Time.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessStructReader.h"
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 7557b87..b3cc9d6 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -11,12 +11,12 @@
#include "Cocoa.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/FunctionCaller.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 98c0926..2b22885 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -13,11 +13,11 @@
#include "NSDictionary.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index ae0ea28..aa1103c 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -10,10 +10,10 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp
index 60486a4..c6bae5e 100644
--- a/lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -13,7 +13,6 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -23,6 +22,7 @@
#include "Plugins/Language/ObjC/NSString.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
index 6b645d5..d962f39 100644
--- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
@@ -8,11 +8,11 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index a895562..59597be 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -9,10 +9,10 @@
#include "NSSet.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp
index bbe05af..65256dc 100644
--- a/lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -8,11 +8,11 @@
#include "NSString.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index d371043..aa69964 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -10,12 +10,12 @@
#include "ObjCLanguage.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
index 508a361..0260212 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
@@ -5,6 +5,7 @@
lldbCore
lldbSymbol
lldbTarget
+ lldbPluginTypeSystemClang
)
add_subdirectory(ItaniumABI)
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index f106b14..6434884 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -18,9 +18,9 @@
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
index 52c297d..5ab4944 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
@@ -8,4 +8,5 @@
lldbSymbol
lldbTarget
lldbPluginCPPRuntime
+ lldbPluginTypeSystemClang
)
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index eed1fb7..097e5ee 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -8,6 +8,7 @@
#include "ItaniumABILanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
@@ -20,7 +21,6 @@
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeList.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index 2701f5b..0ac0c57 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -8,10 +8,10 @@
#include "AppleObjCDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Log.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
index eee8027..0d66cc7 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
@@ -9,11 +9,11 @@
#ifndef liblldb_AppleObjCDeclVendor_h_
#define liblldb_AppleObjCDeclVendor_h_
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/lldb-private.h"
#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
namespace lldb_private {
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 686c2cf..f8f0d56 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -23,7 +23,6 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -38,6 +37,8 @@
#include "lldb/Utility/StreamString.h"
#include "clang/AST/Type.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
#include <vector>
using namespace lldb;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index 73f1b08..3d3c69a 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -12,12 +12,12 @@
#include "clang/AST/Type.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index e5c816d..8b94234 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -20,6 +20,7 @@
#include "lldb/Symbol/CompilerType.h"
#include "lldb/lldb-enumerations.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
@@ -35,7 +36,6 @@
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/TypeList.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index 611f9b4..9b5e677 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -9,6 +9,7 @@
#include "AppleObjCTrampolineHandler.h"
#include "AppleThreadPlanStepThroughObjCTrampoline.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
@@ -18,7 +19,6 @@
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index 7e72f94..5f9bf5d 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -8,8 +8,8 @@
#include "AppleObjCTypeEncodingParser.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
index bcf3240..3789f56 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
@@ -19,6 +19,7 @@
lldbUtility
lldbPluginExpressionParserClang
lldbPluginCPPRuntime
+ lldbPluginTypeSystemClang
CLANG_LIBS
clangAST
LINK_COMPONENTS
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 3ce672f..a9e48e2 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -9,11 +9,11 @@
#include "ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/MappedHash.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Type.h"
diff --git a/lldb/source/Plugins/Platform/POSIX/CMakeLists.txt b/lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
index 749407d..c4c62e4 100644
--- a/lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
@@ -7,4 +7,5 @@
lldbHost
lldbInterpreter
lldbTarget
+ lldbPluginTypeSystemClang
)
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 0185ba4..4bd6509 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -8,6 +8,7 @@
#include "PlatformPOSIX.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -22,7 +23,6 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ProcessLaunchInfo.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
index 4a3bc81..49de7df 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -53,6 +53,7 @@
lldbPluginObjCLanguage
lldbPluginCPlusPlusLanguage
lldbPluginExpressionParserClang
+ lldbPluginTypeSystemClang
CLANG_LIBS
clangAST
clangBasic
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index db49010..f86460a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -17,13 +17,13 @@
#include "SymbolFileDWARFDebugMap.h"
#include "UniqueDWARFASTType.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Host/Host.h"
-#include "lldb/Symbol/ClangASTImporter.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 6cd2dc8..9282131 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -21,8 +21,9 @@
#include "LogChannelDWARF.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include <vector>
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 5ef2dd3..2d7ffde 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -34,9 +34,9 @@
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
index aaecec4..4f19231 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
@@ -14,6 +14,7 @@
lldbCore
lldbSymbol
lldbUtility
+ lldbPluginTypeSystemClang
CLANG_LIBS
clangAST
clangLex
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index aa9fff3..1e9c24e 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -14,11 +14,11 @@
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/Demangle/MicrosoftDemangle.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/LLDBAssert.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
index 78f19b8..f31eeb5 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
@@ -12,7 +12,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "PdbIndex.h"
#include "PdbSymUid.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 85ce87e..73dec53 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -14,13 +14,13 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Type.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamBuffer.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
index 9ecd4e2..308ba9e 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
@@ -5,8 +5,8 @@
#include "PdbSymUid.h"
#include "PdbUtil.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/lldb-enumerations.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
index 5539758..1b08278 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
@@ -9,7 +9,7 @@
#ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
diff --git a/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
index 79bdce42..ceeb173 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt
@@ -8,6 +8,7 @@
lldbPluginSymbolFileNativePDB
lldbSymbol
lldbUtility
+ lldbPluginTypeSystemClang
CLANG_LIBS
clangAST
clangLex
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 010a9ea..48bc572 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -14,10 +14,10 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeMap.h"
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
index 6ded624..06ae32c6 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
@@ -11,7 +11,7 @@
#include "lldb/lldb-forward.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
class SymbolFilePDB;
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 04a9dae..5f1ff5d 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -13,9 +13,9 @@
#include "clang/Lex/Lexer.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
index cb7311ce..fc5c5a6 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
@@ -8,13 +8,12 @@
#include "AppleGetItemInfoHandler.h"
-
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
index 5cd426e..2c22035 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
@@ -8,13 +8,12 @@
#include "AppleGetPendingItemsHandler.h"
-
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
index 2848851..574e327 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
@@ -8,12 +8,12 @@
#include "AppleGetQueuesHandler.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
index af4f0b2..c86d406 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
@@ -8,14 +8,13 @@
#include "AppleGetThreadItemInfoHandler.h"
-
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/Expression.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt b/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt
index ac5781b..04d3065 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt
@@ -14,4 +14,5 @@
lldbTarget
lldbUtility
lldbPluginProcessUtility
+ lldbPluginTypeSystemClang
)
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index f96a7dc..7264511 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "Plugins/Process/Utility/HistoryThread.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Process.h"
diff --git a/lldb/source/Plugins/TypeSystem/CMakeLists.txt b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
new file mode 100644
index 0000000..17c40ae
--- /dev/null
+++ b/lldb/source/Plugins/TypeSystem/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(Clang)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt b/lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt
new file mode 100644
index 0000000..37a3142
--- /dev/null
+++ b/lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt
@@ -0,0 +1,20 @@
+add_lldb_library(lldbPluginTypeSystemClang PLUGIN
+ TypeSystemClang.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginExpressionParserClang
+ lldbPluginSymbolFileDWARF
+ lldbPluginSymbolFilePDB
+ lldbPluginObjCRuntime
+ CLANG_LIBS
+ clangAST
+ clangBasic
+ clangFrontend
+ clangSema
+ LINK_COMPONENTS
+ Support
+)
diff --git a/lldb/source/Symbol/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
similarity index 99%
rename from lldb/source/Symbol/TypeSystemClang.cpp
rename to lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 77e89eb..ef5d376 100644
--- a/lldb/source/Symbol/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/TypeSystemClang.h"
+#include "TypeSystemClang.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
@@ -39,9 +39,13 @@
#include "llvm/Support/Signals.h"
#include "llvm/Support/Threading.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
#include "Plugins/ExpressionParser/Clang/ClangFunctionCaller.h"
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Flags.h"
@@ -52,10 +56,6 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/ClangASTImporter.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Target/ExecutionContext.h"
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
new file mode 100644
index 0000000..fd8276d
--- /dev/null
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -0,0 +1,1029 @@
+//===-- TypeSystemClang.h ---------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_TypeSystemClang_h_
+#define liblldb_TypeSystemClang_h_
+
+#include <stdint.h>
+
+#include <functional>
+#include <initializer_list>
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTFwd.h"
+#include "clang/AST/TemplateBase.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/SmallVector.h"
+
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "lldb/Core/ClangForward.h"
+#include "lldb/Expression/ExpressionVariable.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h"
+#include "lldb/lldb-enumerations.h"
+
+class DWARFASTParserClang;
+class PDBASTParser;
+
+namespace lldb_private {
+
+class Declaration;
+
+class TypeSystemClang : public TypeSystem {
+ // LLVM RTTI support
+ static char ID;
+
+public:
+ typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
+ typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton,
+ clang::ObjCInterfaceDecl *);
+
+ // llvm casting support
+ bool isA(const void *ClassID) const override { return ClassID == &ID; }
+ static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
+
+ /// Constructs a TypeSystemClang with an ASTContext using the given triple.
+ ///
+ /// \param name The name for the TypeSystemClang (for logging purposes)
+ /// \param triple The llvm::Triple used for the ASTContext. The triple defines
+ /// certain characteristics of the ASTContext and its types
+ /// (e.g., whether certain primitive types exist or what their
+ /// signedness is).
+ explicit TypeSystemClang(llvm::StringRef name, llvm::Triple triple);
+
+ /// Constructs a TypeSystemClang that uses an existing ASTContext internally.
+ /// Useful when having an existing ASTContext created by Clang.
+ ///
+ /// \param name The name for the TypeSystemClang (for logging purposes)
+ /// \param existing_ctxt An existing ASTContext.
+ explicit TypeSystemClang(llvm::StringRef name,
+ clang::ASTContext &existing_ctxt);
+
+ ~TypeSystemClang() override;
+
+ void Finalize() override;
+
+ // PluginInterface functions
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
+
+ static ConstString GetPluginNameStatic();
+
+ static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
+ Module *module, Target *target);
+
+ static LanguageSet GetSupportedLanguagesForTypes();
+ static LanguageSet GetSupportedLanguagesForExpressions();
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx);
+
+ static TypeSystemClang *GetScratch(Target &target,
+ bool create_on_demand = true) {
+ auto type_system_or_err = target.GetScratchTypeSystemForLanguage(
+ lldb::eLanguageTypeC, create_on_demand);
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
+ std::move(err), "Couldn't get scratch TypeSystemClang");
+ return nullptr;
+ }
+ return llvm::dyn_cast<TypeSystemClang>(&type_system_or_err.get());
+ }
+
+ /// Returns the display name of this TypeSystemClang that indicates what
+ /// purpose it serves in LLDB. Used for example in logs.
+ llvm::StringRef getDisplayName() const { return m_display_name; }
+
+ clang::ASTContext &getASTContext();
+
+ clang::MangleContext *getMangleContext();
+
+ std::shared_ptr<clang::TargetOptions> &getTargetOptions();
+
+ clang::TargetInfo *getTargetInfo();
+
+ void setSema(clang::Sema *s);
+ clang::Sema *getSema() { return m_sema; }
+
+ const char *GetTargetTriple();
+
+ void SetExternalSource(
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);
+
+ bool GetCompleteDecl(clang::Decl *decl) {
+ return TypeSystemClang::GetCompleteDecl(&getASTContext(), decl);
+ }
+
+ static void DumpDeclHiearchy(clang::Decl *decl);
+
+ static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx);
+
+ static bool DeclsAreEquivalent(clang::Decl *lhs_decl, clang::Decl *rhs_decl);
+
+ static bool GetCompleteDecl(clang::ASTContext *ast, clang::Decl *decl);
+
+ void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id);
+ void SetMetadataAsUserID(const clang::Type *type, lldb::user_id_t user_id);
+
+ void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data);
+
+ void SetMetadata(const clang::Type *object, ClangASTMetadata &meta_data);
+ ClangASTMetadata *GetMetadata(const clang::Decl *object);
+ ClangASTMetadata *GetMetadata(const clang::Type *object);
+
+ // Basic Types
+ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
+ size_t bit_size) override;
+
+ CompilerType GetBasicType(lldb::BasicType type);
+
+ static lldb::BasicType GetBasicTypeEnumeration(ConstString name);
+
+ CompilerType
+ GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name,
+ uint32_t dw_ate, uint32_t bit_size);
+
+ CompilerType GetCStringType(bool is_const);
+
+ static clang::DeclContext *GetDeclContextForType(clang::QualType type);
+
+ static clang::DeclContext *GetDeclContextForType(const CompilerType &type);
+
+ uint32_t GetPointerByteSize() override;
+
+ clang::TranslationUnitDecl *GetTranslationUnitDecl() {
+ return getASTContext().getTranslationUnitDecl();
+ }
+
+ static bool AreTypesSame(CompilerType type1, CompilerType type2,
+ bool ignore_qualifiers = false);
+
+ /// Creates a CompilerType form the given QualType with the current
+ /// TypeSystemClang instance as the CompilerType's typesystem.
+ /// \param qt The QualType for a type that belongs to the ASTContext of this
+ /// TypeSystemClang.
+ /// \return The CompilerType representing the given QualType. If the
+ /// QualType's type pointer is a nullptr then the function returns an
+ /// invalid CompilerType.
+ CompilerType GetType(clang::QualType qt) {
+ if (qt.getTypePtrOrNull() == nullptr)
+ return CompilerType();
+ // Check that the type actually belongs to this TypeSystemClang.
+ assert(qt->getAsTagDecl() == nullptr ||
+ &qt->getAsTagDecl()->getASTContext() == &getASTContext());
+ return CompilerType(this, qt.getAsOpaquePtr());
+ }
+
+ CompilerType GetTypeForDecl(clang::NamedDecl *decl);
+
+ CompilerType GetTypeForDecl(clang::TagDecl *decl);
+
+ CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl);
+
+ template <typename RecordDeclType>
+ CompilerType
+ GetTypeForIdentifier(ConstString type_name,
+ clang::DeclContext *decl_context = nullptr) {
+ CompilerType compiler_type;
+
+ if (type_name.GetLength()) {
+ clang::ASTContext &ast = getASTContext();
+ if (!decl_context)
+ decl_context = ast.getTranslationUnitDecl();
+
+ clang::IdentifierInfo &myIdent = ast.Idents.get(type_name.GetCString());
+ clang::DeclarationName myName =
+ ast.DeclarationNames.getIdentifier(&myIdent);
+
+ clang::DeclContext::lookup_result result = decl_context->lookup(myName);
+
+ if (!result.empty()) {
+ clang::NamedDecl *named_decl = result[0];
+ if (const RecordDeclType *record_decl =
+ llvm::dyn_cast<RecordDeclType>(named_decl))
+ compiler_type.SetCompilerType(
+ this, clang::QualType(record_decl->getTypeForDecl(), 0)
+ .getAsOpaquePtr());
+ }
+ }
+
+ return compiler_type;
+ }
+
+ CompilerType CreateStructForIdentifier(
+ ConstString type_name,
+ const std::initializer_list<std::pair<const char *, CompilerType>>
+ &type_fields,
+ bool packed = false);
+
+ CompilerType GetOrCreateStructForIdentifier(
+ ConstString type_name,
+ const std::initializer_list<std::pair<const char *, CompilerType>>
+ &type_fields,
+ bool packed = false);
+
+ static bool IsOperator(llvm::StringRef name,
+ clang::OverloadedOperatorKind &op_kind);
+
+ // Structure, Unions, Classes
+
+ static clang::AccessSpecifier
+ ConvertAccessTypeToAccessSpecifier(lldb::AccessType access);
+
+ static clang::AccessSpecifier
+ UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs);
+
+ static uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl,
+ bool omit_empty_base_classes);
+
+ CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
+ lldb::AccessType access_type,
+ llvm::StringRef name, int kind,
+ lldb::LanguageType language,
+ ClangASTMetadata *metadata = nullptr,
+ bool exports_symbols = false);
+
+ class TemplateParameterInfos {
+ public:
+ bool IsValid() const {
+ if (args.empty())
+ return false;
+ return args.size() == names.size() &&
+ ((bool)pack_name == (bool)packed_args) &&
+ (!packed_args || !packed_args->packed_args);
+ }
+
+ llvm::SmallVector<const char *, 2> names;
+ llvm::SmallVector<clang::TemplateArgument, 2> args;
+
+ const char * pack_name = nullptr;
+ std::unique_ptr<TemplateParameterInfos> packed_args;
+ };
+
+ clang::FunctionTemplateDecl *
+ CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx,
+ clang::FunctionDecl *func_decl, const char *name,
+ const TemplateParameterInfos &infos);
+
+ void CreateFunctionTemplateSpecializationInfo(
+ clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template,
+ const TemplateParameterInfos &infos);
+
+ clang::ClassTemplateDecl *
+ CreateClassTemplateDecl(clang::DeclContext *decl_ctx,
+ lldb::AccessType access_type, const char *class_name,
+ int kind, const TemplateParameterInfos &infos);
+
+ clang::TemplateTemplateParmDecl *
+ CreateTemplateTemplateParmDecl(const char *template_name);
+
+ clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl(
+ clang::DeclContext *decl_ctx,
+ clang::ClassTemplateDecl *class_template_decl, int kind,
+ const TemplateParameterInfos &infos);
+
+ CompilerType
+ CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *
+ class_template_specialization_decl);
+
+ static clang::DeclContext *
+ GetAsDeclContext(clang::FunctionDecl *function_decl);
+
+ static bool CheckOverloadedOperatorKindParameterCount(
+ bool is_method, clang::OverloadedOperatorKind op_kind,
+ uint32_t num_params);
+
+ bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size);
+
+ static bool RecordHasFields(const clang::RecordDecl *record_decl);
+
+ CompilerType CreateObjCClass(llvm::StringRef name,
+ clang::DeclContext *decl_ctx, bool isForwardDecl,
+ bool isInternal,
+ ClangASTMetadata *metadata = nullptr);
+
+ bool SetTagTypeKind(clang::QualType type, int kind) const;
+
+ bool SetDefaultAccessForRecordFields(clang::RecordDecl *record_decl,
+ int default_accessibility,
+ int *assigned_accessibilities,
+ size_t num_assigned_accessibilities);
+
+ // Returns a mask containing bits from the TypeSystemClang::eTypeXXX
+ // enumerations
+
+ // Namespace Declarations
+
+ clang::NamespaceDecl *
+ GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx,
+ bool is_inline = false);
+
+ // Function Types
+
+ clang::FunctionDecl *
+ CreateFunctionDeclaration(clang::DeclContext *decl_ctx, const char *name,
+ const CompilerType &function_Type, int storage,
+ bool is_inline);
+
+ CompilerType CreateFunctionType(const CompilerType &result_type,
+ const CompilerType *args, unsigned num_args,
+ bool is_variadic, unsigned type_quals,
+ clang::CallingConv cc);
+
+ CompilerType CreateFunctionType(const CompilerType &result_type,
+ const CompilerType *args, unsigned num_args,
+ bool is_variadic, unsigned type_quals) {
+ return CreateFunctionType(result_type, args, num_args, is_variadic,
+ type_quals, clang::CC_C);
+ }
+
+ clang::ParmVarDecl *CreateParameterDeclaration(clang::DeclContext *decl_ctx,
+ const char *name,
+ const CompilerType ¶m_type,
+ int storage,
+ bool add_decl=false);
+
+ void SetFunctionParameters(clang::FunctionDecl *function_decl,
+ clang::ParmVarDecl **params, unsigned num_params);
+
+ CompilerType CreateBlockPointerType(const CompilerType &function_type);
+
+ // Array Types
+
+ CompilerType CreateArrayType(const CompilerType &element_type,
+ size_t element_count, bool is_vector);
+
+ // Enumeration Types
+ CompilerType CreateEnumerationType(const char *name,
+ clang::DeclContext *decl_ctx,
+ const Declaration &decl,
+ const CompilerType &integer_qual_type,
+ bool is_scoped);
+
+ // Integer type functions
+
+ CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed);
+
+ CompilerType GetPointerSizedIntType(bool is_signed);
+
+ // Floating point functions
+
+ static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast,
+ size_t bit_size);
+
+ // TypeSystem methods
+ DWARFASTParser *GetDWARFParser() override;
+ PDBASTParser *GetPDBParser() override;
+
+ // TypeSystemClang callbacks for external source lookups.
+ void CompleteTagDecl(clang::TagDecl *);
+
+ void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *);
+
+ bool LayoutRecordType(
+ const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &base_offsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &vbase_offsets);
+
+ /// Creates a CompilerDecl from the given Decl with the current
+ /// TypeSystemClang instance as its typesystem.
+ /// The Decl has to come from the ASTContext of this
+ /// TypeSystemClang.
+ CompilerDecl GetCompilerDecl(clang::Decl *decl) {
+ assert(&decl->getASTContext() == &getASTContext() &&
+ "CreateCompilerDecl for Decl from wrong ASTContext?");
+ return CompilerDecl(this, decl);
+ }
+
+ // CompilerDecl override functions
+ ConstString DeclGetName(void *opaque_decl) override;
+
+ ConstString DeclGetMangledName(void *opaque_decl) override;
+
+ CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override;
+
+ CompilerType DeclGetFunctionReturnType(void *opaque_decl) override;
+
+ size_t DeclGetFunctionNumArguments(void *opaque_decl) override;
+
+ CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
+ size_t arg_idx) override;
+
+ CompilerType GetTypeForDecl(void *opaque_decl) override;
+
+ // CompilerDeclContext override functions
+
+ /// Creates a CompilerDeclContext from the given DeclContext
+ /// with the current TypeSystemClang instance as its typesystem.
+ /// The DeclContext has to come from the ASTContext of this
+ /// TypeSystemClang.
+ CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);
+
+ std::vector<CompilerDecl>
+ DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
+ const bool ignore_using_decls) override;
+
+ ConstString DeclContextGetName(void *opaque_decl_ctx) override;
+
+ ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override;
+
+ bool DeclContextIsClassMethod(void *opaque_decl_ctx,
+ lldb::LanguageType *language_ptr,
+ bool *is_instance_method_ptr,
+ ConstString *language_object_name_ptr) override;
+
+ bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
+ void *other_opaque_decl_ctx) override;
+
+ // Clang specific clang::DeclContext functions
+
+ static clang::DeclContext *
+ DeclContextGetAsDeclContext(const CompilerDeclContext &dc);
+
+ static clang::ObjCMethodDecl *
+ DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc);
+
+ static clang::CXXMethodDecl *
+ DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc);
+
+ static clang::FunctionDecl *
+ DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc);
+
+ static clang::NamespaceDecl *
+ DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc);
+
+ static ClangASTMetadata *DeclContextGetMetaData(const CompilerDeclContext &dc,
+ const clang::Decl *object);
+
+ static clang::ASTContext *
+ DeclContextGetTypeSystemClang(const CompilerDeclContext &dc);
+
+ // Tests
+
+ bool IsArrayType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size,
+ bool *is_incomplete) override;
+
+ bool IsVectorType(lldb::opaque_compiler_type_t type,
+ CompilerType *element_type, uint64_t *size) override;
+
+ bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsAnonymousType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCharType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsConst(lldb::opaque_compiler_type_t type) override;
+
+ bool IsCStringType(lldb::opaque_compiler_type_t type,
+ uint32_t &length) override;
+
+ static bool IsCXXClassType(const CompilerType &type);
+
+ bool IsDefined(lldb::opaque_compiler_type_t type) override;
+
+ bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
+ bool &is_complex) override;
+
+ bool IsFunctionType(lldb::opaque_compiler_type_t type,
+ bool *is_variadic_ptr) override;
+
+ uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+ CompilerType *base_type_ptr) override;
+
+ size_t
+ GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+ const size_t index) override;
+
+ bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *function_pointer_type_ptr) override;
+
+ bool IsIntegerType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) override;
+
+ bool IsEnumerationType(lldb::opaque_compiler_type_t type,
+ bool &is_signed) override;
+
+ static bool IsObjCClassType(const CompilerType &type);
+
+ static bool IsObjCClassTypeAndHasIVars(const CompilerType &type,
+ bool check_superclass);
+
+ static bool IsObjCObjectOrInterfaceType(const CompilerType &type);
+
+ static bool IsObjCObjectPointerType(const CompilerType &type,
+ CompilerType *target_type = nullptr);
+
+ bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
+
+ static bool IsClassType(lldb::opaque_compiler_type_t type);
+
+ static bool IsEnumType(lldb::opaque_compiler_type_t type);
+
+ bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+ CompilerType *target_type, // Can pass nullptr
+ bool check_cplusplus, bool check_objc) override;
+
+ bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsPointerType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type) override;
+
+ bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type) override;
+
+ bool IsReferenceType(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_type, bool *is_rvalue) override;
+
+ bool IsScalarType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
+
+ bool IsVoidType(lldb::opaque_compiler_type_t type) override;
+
+ bool CanPassInRegisters(const CompilerType &type) override;
+
+ bool SupportsLanguage(lldb::LanguageType language) override;
+
+ static llvm::Optional<std::string> GetCXXClassName(const CompilerType &type);
+
+ // Type Completion
+
+ bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
+
+ // Accessors
+
+ ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
+ CompilerType *pointee_or_element_compiler_type) override;
+
+ lldb::LanguageType
+ GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
+
+ lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
+
+ unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
+
+ // Creating related types
+
+ // Using the current type, create a new typedef to that type using
+ // "typedef_name" as the name and "decl_ctx" as the decl context.
+ static CompilerType
+ CreateTypedefType(const CompilerType &type, const char *typedef_name,
+ const CompilerDeclContext &compiler_decl_ctx);
+
+ CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
+ uint64_t *stride) override;
+
+ CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
+ uint64_t size) override;
+
+ CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
+
+ // Returns -1 if this isn't a function of if the function doesn't have a
+ // prototype Returns a value >= 0 if there is a prototype.
+ int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+
+ CompilerType
+ GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
+
+ size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
+
+ TypeMemberFunctionImpl
+ GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+
+ CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetLValueReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType
+ GetRValueReferenceType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
+ const char *name,
+ const CompilerDeclContext &decl_ctx) override;
+
+ // If the current object represents a typedef type, get the underlying type
+ CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
+
+ // Create related types using the current type's AST
+ CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
+
+ // Exploring the type
+
+ const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) override;
+
+ llvm::Optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) {
+ if (llvm::Optional<uint64_t> bit_size = GetBitSize(type, exe_scope))
+ return (*bit_size + 7) / 8;
+ return llvm::None;
+ }
+
+ llvm::Optional<uint64_t>
+ GetBitSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) override;
+
+ lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type,
+ uint64_t &count) override;
+
+ lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
+
+ llvm::Optional<size_t>
+ GetTypeBitAlign(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) override;
+
+ uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
+ bool omit_empty_base_classes,
+ const ExecutionContext *exe_ctx) override;
+
+ CompilerType GetBuiltinTypeByName(ConstString name) override;
+
+ lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
+
+ static lldb::BasicType
+ GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type,
+ ConstString name);
+
+ void ForEachEnumerator(
+ lldb::opaque_compiler_type_t type,
+ std::function<bool(const CompilerType &integer_type,
+ ConstString name,
+ const llvm::APSInt &value)> const &callback) override;
+
+ uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
+ std::string &name, uint64_t *bit_offset_ptr,
+ uint32_t *bitfield_bit_size_ptr,
+ bool *is_bitfield_ptr) override;
+
+ uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override;
+
+ uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override;
+
+ CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
+
+ CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type,
+ size_t idx,
+ uint32_t *bit_offset_ptr) override;
+
+ static uint32_t GetNumPointeeChildren(clang::QualType type);
+
+ CompilerType GetChildCompilerTypeAtIndex(
+ lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
+ bool transparent_pointers, bool omit_empty_base_classes,
+ bool ignore_array_bounds, std::string &child_name,
+ uint32_t &child_byte_size, int32_t &child_byte_offset,
+ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
+ bool &child_is_base_class, bool &child_is_deref_of_parent,
+ ValueObject *valobj, uint64_t &language_flags) override;
+
+ // Lookup a child given a name. This function will match base class names and
+ // member member names in "clang_type" only, not descendants.
+ uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+ const char *name,
+ bool omit_empty_base_classes) override;
+
+ // Lookup a child member given a name. This function will match member names
+ // only and will descend into "clang_type" children in search for the first
+ // member in this class, or any base class that matches "name".
+ // TODO: Return all matches for a given name by returning a
+ // vector<vector<uint32_t>>
+ // so we catch all names that match a given child name, not just the first.
+ size_t
+ GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
+ const char *name, bool omit_empty_base_classes,
+ std::vector<uint32_t> &child_indexes) override;
+
+ size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override;
+
+ lldb::TemplateArgumentKind
+ GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+ CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+ llvm::Optional<CompilerType::IntegralTemplateArgument>
+ GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type,
+ size_t idx) override;
+
+ CompilerType GetTypeForFormatters(void *type) override;
+
+#define LLDB_INVALID_DECL_LEVEL UINT32_MAX
+ // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if child_decl_ctx
+ // could not be found in decl_ctx.
+ uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx,
+ clang::DeclContext *child_decl_ctx,
+ ConstString *child_name = nullptr,
+ CompilerType *child_type = nullptr);
+
+ // Modifying RecordType
+ static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
+ llvm::StringRef name,
+ const CompilerType &field_type,
+ lldb::AccessType access,
+ uint32_t bitfield_bit_size);
+
+ static void BuildIndirectFields(const CompilerType &type);
+
+ static void SetIsPacked(const CompilerType &type);
+
+ static clang::VarDecl *AddVariableToRecordType(const CompilerType &type,
+ llvm::StringRef name,
+ const CompilerType &var_type,
+ lldb::AccessType access);
+
+ clang::CXXMethodDecl *AddMethodToCXXRecordType(
+ lldb::opaque_compiler_type_t type, llvm::StringRef name,
+ const char *mangled_name, const CompilerType &method_type,
+ lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline,
+ bool is_explicit, bool is_attr_used, bool is_artificial);
+
+ void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type);
+
+ // C++ Base Classes
+ std::unique_ptr<clang::CXXBaseSpecifier>
+ CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
+ lldb::AccessType access, bool is_virtual,
+ bool base_of_class);
+
+ bool TransferBaseClasses(
+ lldb::opaque_compiler_type_t type,
+ std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases);
+
+ static bool SetObjCSuperClass(const CompilerType &type,
+ const CompilerType &superclass_compiler_type);
+
+ static bool AddObjCClassProperty(const CompilerType &type,
+ const char *property_name,
+ const CompilerType &property_compiler_type,
+ clang::ObjCIvarDecl *ivar_decl,
+ const char *property_setter_name,
+ const char *property_getter_name,
+ uint32_t property_attributes,
+ ClangASTMetadata *metadata);
+
+ static clang::ObjCMethodDecl *AddMethodToObjCObjectType(
+ const CompilerType &type,
+ const char *name, // the full symbol name as seen in the symbol table
+ // (lldb::opaque_compiler_type_t type, "-[NString
+ // stringWithCString:]")
+ const CompilerType &method_compiler_type, lldb::AccessType access,
+ bool is_artificial, bool is_variadic, bool is_objc_direct_call);
+
+ static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type,
+ bool has_extern);
+
+ // Tag Declarations
+ static bool StartTagDeclarationDefinition(const CompilerType &type);
+
+ static bool CompleteTagDeclarationDefinition(const CompilerType &type);
+
+ // Modifying Enumeration types
+ clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
+ const CompilerType &enum_type, const Declaration &decl, const char *name,
+ int64_t enum_value, uint32_t enum_value_bit_size);
+ clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
+ const CompilerType &enum_type, const Declaration &decl, const char *name,
+ const llvm::APSInt &value);
+
+ CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type);
+
+ // Pointers & References
+
+ // Call this function using the class type when you want to make a member
+ // pointer type to pointee_type.
+ static CompilerType CreateMemberPointerType(const CompilerType &type,
+ const CompilerType &pointee_type);
+
+ // Dumping types
+#ifndef NDEBUG
+ /// Convenience LLVM-style dump method for use in the debugger only.
+ /// In contrast to the other \p Dump() methods this directly invokes
+ /// \p clang::QualType::dump().
+ LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
+#endif
+
+ void Dump(Stream &s);
+
+ /// Dump clang AST types from the symbol file.
+ ///
+ /// \param[in] s
+ /// A stream to send the dumped AST node(s) to
+ /// \param[in] symbol_name
+ /// The name of the symbol to dump, if it is empty dump all the symbols
+ void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name);
+
+ void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ bool show_types, bool show_summary, bool verbose,
+ uint32_t depth) override;
+
+ bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::Format format, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ ExecutionContextScope *exe_scope) override;
+
+ void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+ Stream *s, const DataExtractor &data,
+ lldb::offset_t data_offset, size_t data_byte_size) override;
+
+ void DumpTypeDescription(
+ lldb::opaque_compiler_type_t type) override; // Dump to stdout
+
+ void DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ Stream *s) override;
+
+ static void DumpTypeName(const CompilerType &type);
+
+ static clang::EnumDecl *GetAsEnumDecl(const CompilerType &type);
+
+ static clang::RecordDecl *GetAsRecordDecl(const CompilerType &type);
+
+ static clang::TagDecl *GetAsTagDecl(const CompilerType &type);
+
+ static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType &type);
+
+ static clang::CXXRecordDecl *
+ GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type);
+
+ static clang::ObjCInterfaceDecl *
+ GetAsObjCInterfaceDecl(const CompilerType &type);
+
+ clang::ClassTemplateDecl *ParseClassTemplateDecl(
+ clang::DeclContext *decl_ctx, lldb::AccessType access_type,
+ const char *parent_name, int tag_decl_kind,
+ const TypeSystemClang::TemplateParameterInfos &template_param_infos);
+
+ clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx);
+
+ clang::UsingDirectiveDecl *
+ CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx,
+ clang::NamespaceDecl *ns_decl);
+
+ clang::UsingDecl *CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
+ clang::NamedDecl *target);
+
+ clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context,
+ const char *name,
+ clang::QualType type);
+
+ static lldb::opaque_compiler_type_t
+ GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type);
+
+ static clang::QualType GetQualType(lldb::opaque_compiler_type_t type) {
+ if (type)
+ return clang::QualType::getFromOpaquePtr(type);
+ return clang::QualType();
+ }
+
+ static clang::QualType
+ GetCanonicalQualType(lldb::opaque_compiler_type_t type) {
+ if (type)
+ return clang::QualType::getFromOpaquePtr(type).getCanonicalType();
+ return clang::QualType();
+ }
+
+ clang::DeclarationName
+ GetDeclarationName(const char *name, const CompilerType &function_clang_type);
+
+private:
+ const clang::ClassTemplateSpecializationDecl *
+ GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
+
+ // Classes that inherit from TypeSystemClang can see and modify these
+ std::string m_target_triple;
+ std::unique_ptr<clang::ASTContext> m_ast_up;
+ std::unique_ptr<clang::LangOptions> m_language_options_up;
+ std::unique_ptr<clang::FileManager> m_file_manager_up;
+ std::unique_ptr<clang::SourceManager> m_source_manager_up;
+ std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up;
+ std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up;
+ std::shared_ptr<clang::TargetOptions> m_target_options_rp;
+ std::unique_ptr<clang::TargetInfo> m_target_info_up;
+ std::unique_ptr<clang::IdentifierTable> m_identifier_table_up;
+ std::unique_ptr<clang::SelectorTable> m_selector_table_up;
+ std::unique_ptr<clang::Builtin::Context> m_builtins_up;
+ std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
+ std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
+ std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
+ uint32_t m_pointer_byte_size = 0;
+ bool m_ast_owned = false;
+ /// A string describing what this TypeSystemClang represents (e.g.,
+ /// AST for debug information, an expression, some other utility ClangAST).
+ /// Useful for logging and debugging.
+ std::string m_display_name;
+
+ typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap;
+ /// Maps Decls to their associated ClangASTMetadata.
+ DeclMetadataMap m_decl_metadata;
+
+ typedef llvm::DenseMap<const clang::Type *, ClangASTMetadata> TypeMetadataMap;
+ /// Maps Types to their associated ClangASTMetadata.
+ TypeMetadataMap m_type_metadata;
+
+ /// The sema associated that is currently used to build this ASTContext.
+ /// May be null if we are already done parsing this ASTContext or the
+ /// ASTContext wasn't created by parsing source code.
+ clang::Sema *m_sema = nullptr;
+
+ // For TypeSystemClang only
+ TypeSystemClang(const TypeSystemClang &);
+ const TypeSystemClang &operator=(const TypeSystemClang &);
+ /// Creates the internal ASTContext.
+ void CreateASTContext();
+ void SetTargetTriple(llvm::StringRef target_triple);
+};
+
+class TypeSystemClangForExpressions : public TypeSystemClang {
+public:
+ TypeSystemClangForExpressions(Target &target, llvm::Triple triple);
+
+ ~TypeSystemClangForExpressions() override = default;
+
+ void Finalize() override;
+
+ UserExpression *
+ GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
+ lldb::LanguageType language,
+ Expression::ResultType desired_type,
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj) override;
+
+ FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
+ const Address &function_address,
+ const ValueList &arg_value_list,
+ const char *name) override;
+
+ UtilityFunction *GetUtilityFunction(const char *text,
+ const char *name) override;
+
+ PersistentExpressionState *GetPersistentExpressionState() override;
+private:
+ lldb::TargetWP m_target_wp;
+ std::unique_ptr<ClangPersistentVariables>
+ m_persistent_variables; // These are the persistent variables associated
+ // with this process for the expression parser
+ std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_TypeSystemClang_h_
diff --git a/lldb/source/Symbol/CMakeLists.txt b/lldb/source/Symbol/CMakeLists.txt
index 46fb9a8..95bf156 100644
--- a/lldb/source/Symbol/CMakeLists.txt
+++ b/lldb/source/Symbol/CMakeLists.txt
@@ -7,17 +7,11 @@
add_lldb_library(lldbSymbol
ArmUnwindInfo.cpp
Block.cpp
- TypeSystemClang.cpp
- ClangASTImporter.cpp
- ClangASTMetadata.cpp
- ClangExternalASTSourceCallbacks.cpp
- ClangUtil.cpp
CompactUnwindInfo.cpp
CompileUnit.cpp
CompilerDecl.cpp
CompilerDeclContext.cpp
CompilerType.cpp
- CxxModuleHandler.cpp
DWARFCallFrameInfo.cpp
DebugMacros.cpp
Declaration.cpp
@@ -51,16 +45,7 @@
lldbHost
lldbTarget
lldbUtility
- lldbPluginExpressionParserClang
- lldbPluginSymbolFileDWARF
- lldbPluginSymbolFilePDB
lldbPluginObjCLanguage
- lldbPluginObjCRuntime
-
- CLANG_LIBS
- clangAST
- clangBasic
- clangFrontend
LINK_COMPONENTS
Support