[Lldb-commits] [lldb] 92d5ea5 - [lldb][NFC] Move TypeSystem RTTI to static variable to remove swift reference
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 27 01:28:24 PST 2019
Author: Raphael Isemann
Date: 2019-11-27T10:28:02+01:00
New Revision: 92d5ea5d1674c38e03d130c6b04afa118e94ef4a
URL: https://github.com/llvm/llvm-project/commit/92d5ea5d1674c38e03d130c6b04afa118e94ef4a
DIFF: https://github.com/llvm/llvm-project/commit/92d5ea5d1674c38e03d130c6b04afa118e94ef4a.diff
LOG: [lldb][NFC] Move TypeSystem RTTI to static variable to remove swift reference
Added:
Modified:
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Symbol/ClangASTContext.cpp
lldb/source/Symbol/CompilerDecl.cpp
lldb/source/Symbol/CompilerDeclContext.cpp
lldb/source/Symbol/TypeSystem.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index f4428c682182..20421bca305e 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -41,15 +41,17 @@ namespace lldb_private {
class Declaration;
class ClangASTContext : 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
- static bool classof(const TypeSystem *ts) {
- return ts->getKind() == TypeSystem::eKindClang;
- }
+ bool isA(const void *ClassID) const override { return ClassID == &ID; }
+ static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
// Constructors and Destructors
explicit ClangASTContext(llvm::StringRef triple = "");
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 6283d67baba5..ea860647fdb1 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -52,47 +52,11 @@ struct LanguageSet {
/// Interface for representing the Type Systems in
diff erent languages.
class TypeSystem : public PluginInterface {
public:
- // Intrusive type system that allows us to use llvm casting.
- //
- // To add a new type system:
- //
- // 1 - Add a new enumeration for llvm casting below for your TypeSystem
- // subclass, here we will use eKindFoo
- //
- // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs
- // to implement a static classof() function that returns your
- // enumeration:
- //
- // class Foo : public lldb_private::TypeSystem
- // {
- // static bool classof(const TypeSystem *ts)
- // {
- // return ts->getKind() == TypeSystem::eKindFoo;
- // }
- // };
- //
- // 3 - Contruct your TypeSystem subclass with the enumeration from below
- //
- // Foo() :
- // TypeSystem(TypeSystem::eKindFoo),
- // ...
- // {
- // }
- //
- // Then you can use the llvm casting on any "TypeSystem *" to get an instance
- // of your subclass.
- enum LLVMCastKind {
- eKindClang,
- eKindSwift,
- kNumKinds
- };
-
// Constructors and Destructors
- TypeSystem(LLVMCastKind kind);
-
~TypeSystem() override;
- LLVMCastKind getKind() const { return m_kind; }
+ // LLVM RTTI support
+ virtual bool isA(const void *ClassID) const = 0;
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
Module *module);
@@ -493,8 +457,7 @@ class TypeSystem : public PluginInterface {
virtual bool IsMeaninglessWithoutDynamicResolution(void *type);
protected:
- const LLVMCastKind m_kind; // Support for llvm casting
- SymbolFile *m_sym_file;
+ SymbolFile *m_sym_file = nullptr;
};
class TypeSystemMap {
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 244ac8ce5ff8..e413029f0300 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -337,6 +337,8 @@ static ClangASTMap &GetASTMap() {
return *g_map_ptr;
}
+char ClangASTContext::ID;
+
bool ClangASTContext::IsOperator(llvm::StringRef name,
clang::OverloadedOperatorKind &op_kind) {
// All operators have to start with "operator".
@@ -522,8 +524,7 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
Opts.NoInlineDefine = !Opt;
}
-ClangASTContext::ClangASTContext(llvm::StringRef target_triple)
- : TypeSystem(TypeSystem::eKindClang) {
+ClangASTContext::ClangASTContext(llvm::StringRef target_triple) {
if (!target_triple.empty())
SetTargetTriple(target_triple);
// The caller didn't pass an ASTContext so create a new one for this
@@ -531,16 +532,14 @@ ClangASTContext::ClangASTContext(llvm::StringRef target_triple)
CreateASTContext();
}
-ClangASTContext::ClangASTContext(ArchSpec arch)
- : TypeSystem(TypeSystem::eKindClang) {
+ClangASTContext::ClangASTContext(ArchSpec arch) {
SetTargetTriple(arch.GetTriple().str());
// The caller didn't pass an ASTContext so create a new one for this
// ClangASTContext.
CreateASTContext();
}
-ClangASTContext::ClangASTContext(ASTContext &existing_ctxt)
- : TypeSystem(TypeSystem::eKindClang) {
+ClangASTContext::ClangASTContext(ASTContext &existing_ctxt) {
SetTargetTriple(existing_ctxt.getTargetInfo().getTriple().str());
m_ast_up.reset(&existing_ctxt);
diff --git a/lldb/source/Symbol/CompilerDecl.cpp b/lldb/source/Symbol/CompilerDecl.cpp
index 2c64113a2bbe..3d17d802dd04 100644
--- a/lldb/source/Symbol/CompilerDecl.cpp
+++ b/lldb/source/Symbol/CompilerDecl.cpp
@@ -7,13 +7,14 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/TypeSystem.h"
using namespace lldb_private;
bool CompilerDecl::IsClang() const {
- return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
+ return IsValid() && llvm::isa<ClangASTContext>(m_type_system);
}
ConstString CompilerDecl::GetName() const {
diff --git a/lldb/source/Symbol/CompilerDeclContext.cpp b/lldb/source/Symbol/CompilerDeclContext.cpp
index a6f046c4eb22..7d45f47ad133 100644
--- a/lldb/source/Symbol/CompilerDeclContext.cpp
+++ b/lldb/source/Symbol/CompilerDeclContext.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/CompilerDeclContext.h"
+#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/TypeSystem.h"
#include <vector>
@@ -24,7 +25,7 @@ CompilerDeclContext::FindDeclByName(ConstString name,
}
bool CompilerDeclContext::IsClang() const {
- return IsValid() && m_type_system->getKind() == TypeSystem::eKindClang;
+ return IsValid() && llvm::isa<ClangASTContext>(m_type_system);
}
ConstString CompilerDeclContext::GetName() const {
diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp
index c63f24aea335..4e746bd18e1f 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -43,8 +43,6 @@ size_t LanguageSet::Size() const { return bitvector.count(); }
bool LanguageSet::Empty() const { return bitvector.none(); }
bool LanguageSet::operator[](unsigned i) const { return bitvector[i]; }
-TypeSystem::TypeSystem(LLVMCastKind kind) : m_kind(kind), m_sym_file(nullptr) {}
-
TypeSystem::~TypeSystem() {}
static lldb::TypeSystemSP CreateInstanceHelper(lldb::LanguageType language,
More information about the lldb-commits
mailing list