summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Symbol/DeclVendor.h21
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp14
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h42
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp3
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h9
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp13
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h8
7 files changed, 81 insertions, 29 deletions
diff --git a/lldb/include/lldb/Symbol/DeclVendor.h b/lldb/include/lldb/Symbol/DeclVendor.h
index 9c10fe1177f..203f34e56cb 100644
--- a/lldb/include/lldb/Symbol/DeclVendor.h
+++ b/lldb/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 <vector>
namespace lldb_private {
@@ -22,11 +20,19 @@ namespace lldb_private {
// 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 @@ public:
/// The vector of CompilerTypes that was found.
std::vector<CompilerType> 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
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index d25b435e7a0..2788e691dbb 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -100,17 +100,15 @@ void ClangASTSource::InstallASTContext(clang::ASTContext &ast_context,
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<ClangDeclVendor>(
+ 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<ClangModulesDeclVendor>(
+ m_target->GetClangModulesDeclVendor());
if (!modules_decl_vendor)
break;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
new file mode 100644
index 00000000000..767a53b7d27
--- /dev/null
+++ b/lldb/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
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index f22c7f515ab..c5692917007 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -147,7 +147,8 @@ void StoringDiagnosticConsumer::DumpDiagnostics(Stream &error_stream) {
}
}
-ClangModulesDeclVendor::ClangModulesDeclVendor() {}
+ClangModulesDeclVendor::ClangModulesDeclVendor()
+ : ClangDeclVendor(eClangModuleDeclVendor) {}
ClangModulesDeclVendor::~ClangModulesDeclVendor() {}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
index d5c8757bdcd..e099b59041d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
+++ b/lldb/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 <set>
#include <vector>
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<ConstString> ModulePath;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index 078543a86ca..3800b81d976 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -151,12 +151,13 @@ private:
};
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<clang::ExternalASTSource> external_source_owning_ptr(
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
index 77b30b7fde7..99ca4b74870 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
+++ b/lldb/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<clang::NamedDecl *> &decls) override;
OpenPOWER on IntegriCloud