Add RTTI support to the SymbolFile class hierarchy
authorAdrian Prantl <aprantl@apple.com>
Fri, 15 Nov 2019 18:13:16 +0000 (10:13 -0800)
committerAdrian Prantl <aprantl@apple.com>
Fri, 15 Nov 2019 19:52:13 +0000 (11:52 -0800)
Differential Revision: https://reviews.llvm.org/D70322

19 files changed:
lldb/include/lldb/Expression/UserExpression.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
lldb/source/Symbol/SymbolFile.cpp

index c669cac..83122d8 100644 (file)
@@ -33,7 +33,7 @@ namespace lldb_private {
 /// implementations of UserExpression - which will be vended through the
 /// appropriate TypeSystem.
 class UserExpression : public Expression {
-  // LLVM RTTI support
+  /// LLVM RTTI support.
   static char ID;
 
 public:
index 9c5e46b..2fb8796 100644 (file)
 namespace lldb_private {
 
 class SymbolFile : public PluginInterface {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   // Symbol file ability bits.
   //
   // Each symbol file can claim to support one or more symbol file abilities.
index c77ddd3..29d2e8a 100644 (file)
@@ -25,6 +25,8 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::breakpad;
 
+char SymbolFileBreakpad::ID;
+
 class SymbolFileBreakpad::LineIterator {
 public:
   // begin iterator for sections of given type
index 1748c64..de27122 100644 (file)
@@ -21,7 +21,18 @@ namespace lldb_private {
 namespace breakpad {
 
 class SymbolFileBreakpad : public SymbolFile {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFile::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   // Static Functions
   static void Initialize();
   static void Terminate();
index b613553..5b50818 100644 (file)
@@ -94,6 +94,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+char SymbolFileDWARF::ID;
+
 // static inline bool
 // child_requires_parent_class_union_or_struct_to_be_completed (dw_tag_t tag)
 //{
index af9407f..1b8633a 100644 (file)
@@ -59,7 +59,18 @@ class SymbolFileDWARFDwp;
 
 class SymbolFileDWARF : public lldb_private::SymbolFile,
                         public lldb_private::UserID {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFile::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   friend class SymbolFileDWARFDebugMap;
   friend class SymbolFileDWARFDwo;
   friend class DebugMapModule;
index 3187620..4cac7e7 100644 (file)
@@ -39,6 +39,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+char SymbolFileDWARFDebugMap::ID;
+
 // Subclass lldb_private::Module so we can intercept the
 // "Module::GetObjectFile()" (so we can fixup the object file sections) and
 // also for "Module::GetSymbolFile()" (so we can fixup the symbol file id.
index 6193fe2..0f47348 100644 (file)
@@ -23,7 +23,18 @@ class DWARFDebugAranges;
 class DWARFDeclContext;
 
 class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFile::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   // Static Functions
   static void Initialize();
 
index b0f7e81..de5f796 100644 (file)
@@ -21,6 +21,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+char SymbolFileDWARFDwo::ID;
+
 SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile,
                                        DWARFCompileUnit &dwarf_cu)
     : SymbolFileDWARF(objfile, objfile->GetSectionList(
index ad290cd..d072097 100644 (file)
 #include "SymbolFileDWARF.h"
 
 class SymbolFileDWARFDwo : public SymbolFileDWARF {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFileDWARF::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu);
 
   ~SymbolFileDWARFDwo() override = default;
index efea192..4288dcb 100644 (file)
@@ -19,6 +19,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+char SymbolFileDWARFDwoDwp::ID;
+
 SymbolFileDWARFDwoDwp::SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
                                              ObjectFileSP objfile,
                                              DWARFCompileUnit &dwarf_cu,
index 2105e1a..a55795b 100644 (file)
 #include "SymbolFileDWARFDwp.h"
 
 class SymbolFileDWARFDwoDwp : public SymbolFileDWARFDwo {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFileDWARFDwo::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
   SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
                         lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu,
                         uint64_t dwo_id);
index 5829a1c..36317af 100644 (file)
@@ -67,6 +67,8 @@ using namespace npdb;
 using namespace llvm::codeview;
 using namespace llvm::pdb;
 
+char SymbolFileNativePDB::ID;
+
 static lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
   switch (lang) {
   case PDB_Lang::Cpp:
index e89cb2c..a37de0f 100644 (file)
@@ -41,7 +41,18 @@ class PdbAstBuilder;
 class SymbolFileNativePDB : public SymbolFile {
   friend class UdtRecordCompleter;
 
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFile::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   // Static Functions
   static void Initialize();
 
index b108cb4..e7bc730 100644 (file)
@@ -58,6 +58,8 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::pdb;
 
+char SymbolFilePDB::ID;
+
 namespace {
 lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
   switch (lang) {
index c041dab..7a4eee4 100644 (file)
 class PDBASTParser;
 
 class SymbolFilePDB : public lldb_private::SymbolFile {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFile::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   // Static Functions
   static void Initialize();
 
index 62da765..305efea 100644 (file)
@@ -25,6 +25,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+char SymbolFileSymtab::ID;
+
 void SymbolFileSymtab::Initialize() {
   PluginManager::RegisterPlugin(GetPluginNameStatic(),
                                 GetPluginDescriptionStatic(), CreateInstance);
index 2ac4660..1fff818 100644 (file)
 #include "lldb/Symbol/Symtab.h"
 
 class SymbolFileSymtab : public lldb_private::SymbolFile {
+  /// LLVM RTTI support.
+  static char ID;
+
 public:
+  /// LLVM RTTI support.
+  /// \{
+  bool isA(const void *ClassID) const override {
+    return ClassID == &ID || SymbolFile::isA(ClassID);
+  }
+  static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
+  /// \}
+
   // Constructors and Destructors
   SymbolFileSymtab(lldb::ObjectFileSP objfile_sp);
 
index f892d09..90f7d10 100644 (file)
@@ -24,6 +24,8 @@
 using namespace lldb_private;
 using namespace lldb;
 
+char SymbolFile::ID;
+
 void SymbolFile::PreloadSymbols() {
   // No-op for most implementations.
 }