Index: lldb/trunk/include/lldb/Symbol/DeclVendor.h =================================================================== --- lldb/trunk/include/lldb/Symbol/DeclVendor.h +++ lldb/trunk/include/lldb/Symbol/DeclVendor.h @@ -12,8 +12,6 @@ #include "lldb/Core/ClangForward.h" #include "lldb/lldb-defines.h" -#include "clang/AST/ExternalASTMerger.h" - #include namespace lldb_private { @@ -22,11 +20,19 @@ // declarations that are not necessarily backed by a specific symbol file. class DeclVendor { public: + enum DeclVendorKind { + eClangDeclVendor, + eClangModuleDeclVendor, + eAppleObjCDeclVendor, + eLastClangDeclVendor, + }; // Constructors and Destructors - DeclVendor() {} + DeclVendor(DeclVendorKind kind) : m_kind(kind) {} virtual ~DeclVendor() {} + DeclVendorKind GetKind() const { return m_kind; } + /// Look up the set of Decls that the DeclVendor currently knows about /// matching a given name. /// @@ -60,16 +66,11 @@ /// The vector of CompilerTypes that was found. std::vector FindTypes(ConstString name, uint32_t max_matches); - /// Interface for ExternalASTMerger. Returns an ImporterSource - /// allowing type completion. - /// - /// \return - /// An ImporterSource for this DeclVendor. - virtual clang::ExternalASTMerger::ImporterSource GetImporterSource() = 0; - private: // For DeclVendor only DISALLOW_COPY_AND_ASSIGN(DeclVendor); + + const DeclVendorKind m_kind; }; } // namespace lldb_private Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -100,17 +100,15 @@ if (!language_runtime) break; - DeclVendor *runtime_decl_vendor = language_runtime->GetDeclVendor(); - - if (!runtime_decl_vendor) - break; - - sources.push_back(runtime_decl_vendor->GetImporterSource()); + if (auto *runtime_decl_vendor = llvm::dyn_cast_or_null( + language_runtime->GetDeclVendor())) { + sources.push_back(runtime_decl_vendor->GetImporterSource()); + } } while (false); do { - DeclVendor *modules_decl_vendor = - m_target->GetClangModulesDeclVendor(); + auto *modules_decl_vendor = llvm::cast( + m_target->GetClangModulesDeclVendor()); if (!modules_decl_vendor) break; Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h @@ -0,0 +1,42 @@ +//===-- ClangDeclVendor.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_ClangDeclVendor_h_ +#define liblldb_ClangDeclVendor_h_ + +#include "lldb/Symbol/DeclVendor.h" + +#include "clang/AST/ExternalASTMerger.h" + +namespace lldb_private { + +// A clang specialized extension to DeclVendor. +class ClangDeclVendor : public DeclVendor { +public: + ClangDeclVendor(DeclVendorKind kind) : DeclVendor(kind) {} + + virtual ~ClangDeclVendor() {} + + /// Interface for ExternalASTMerger. Returns an ImporterSource allowing type + /// completion. + /// + /// \return + /// An ImporterSource for this ClangDeclVendor. + virtual clang::ExternalASTMerger::ImporterSource GetImporterSource() = 0; + + static bool classof(const DeclVendor *vendor) { + return vendor->GetKind() >= eClangDeclVendor && + vendor->GetKind() < eLastClangDeclVendor; + } + +private: + DISALLOW_COPY_AND_ASSIGN(ClangDeclVendor); +}; +}; // namespace lldb_private + +#endif Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h @@ -10,22 +10,27 @@ #define liblldb_ClangModulesDeclVendor_h #include "lldb/Core/ClangForward.h" -#include "lldb/Symbol/DeclVendor.h" #include "lldb/Symbol/SourceModule.h" #include "lldb/Target/Platform.h" +#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h" + #include #include namespace lldb_private { -class ClangModulesDeclVendor : public DeclVendor { +class ClangModulesDeclVendor : public ClangDeclVendor { public: // Constructors and Destructors ClangModulesDeclVendor(); ~ClangModulesDeclVendor() override; + static bool classof(const DeclVendor *vendor) { + return vendor->GetKind() == eClangModuleDeclVendor; + } + static ClangModulesDeclVendor *Create(Target &target); typedef std::vector ModulePath; Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -147,7 +147,8 @@ } } -ClangModulesDeclVendor::ClangModulesDeclVendor() {} +ClangModulesDeclVendor::ClangModulesDeclVendor() + : ClangDeclVendor(eClangModuleDeclVendor) {} ClangModulesDeclVendor::~ClangModulesDeclVendor() {} Index: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h @@ -10,19 +10,23 @@ #define liblldb_AppleObjCDeclVendor_h_ #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/DeclVendor.h" #include "lldb/lldb-private.h" +#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h" #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" namespace lldb_private { class AppleObjCExternalASTSource; -class AppleObjCDeclVendor : public DeclVendor { +class AppleObjCDeclVendor : public ClangDeclVendor { public: AppleObjCDeclVendor(ObjCLanguageRuntime &runtime); + static bool classof(const DeclVendor *vendor) { + return vendor->GetKind() == eAppleObjCDeclVendor; + } + uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches, std::vector &decls) override; Index: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -151,12 +151,13 @@ }; AppleObjCDeclVendor::AppleObjCDeclVendor(ObjCLanguageRuntime &runtime) - : DeclVendor(), m_runtime(runtime), m_ast_ctx(runtime.GetProcess() - ->GetTarget() - .GetArchitecture() - .GetTriple() - .getTriple() - .c_str()), + : ClangDeclVendor(eAppleObjCDeclVendor), m_runtime(runtime), + m_ast_ctx(runtime.GetProcess() + ->GetTarget() + .GetArchitecture() + .GetTriple() + .getTriple() + .c_str()), m_type_realizer_sp(m_runtime.GetEncodingToType()) { m_external_source = new AppleObjCExternalASTSource(*this); llvm::IntrusiveRefCntPtr external_source_owning_ptr(