Skip to content

[lldb][NFC] Implement RTTI for DWARFASTParserSwift #7664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SymbolFileDWARF;

class DWARFASTParser {
public:
enum class Kind { DWARFASTParserClang, DWARFASTParserSwift};
DWARFASTParser(Kind kind) : m_kind(kind) {}

virtual ~DWARFASTParser() = default;

virtual lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
Expand Down Expand Up @@ -64,6 +67,11 @@ class DWARFASTParser {
const lldb_private::ExecutionContext *exe_ctx = nullptr);

static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);

Kind GetKind() const { return m_kind; }

private:
const Kind m_kind;
};

#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSER_H
3 changes: 2 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::dwarf;
DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast)
: m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
: DWARFASTParser(Kind::DWARFASTParserClang), m_ast(ast),
m_die_to_decl_ctx(), m_decl_ctx_to_die() {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the commit should be made upstream.

Copy link
Author

@augusto2112 augusto2112 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first two commits are cherry picks from upstream

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the () initializers are redundant.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!


DWARFASTParserClang::~DWARFASTParserClang() = default;

Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ class DWARFASTParserClang : public DWARFASTParser {
// module.
lldb::ModuleSP GetModuleForType(const DWARFDIE &die);

static bool classof(const DWARFASTParser *Parser) {
return Parser->GetKind() == Kind::DWARFASTParserClang;
}

private:
struct FieldInfo {
uint64_t bit_size = 0;
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ using namespace lldb_private::dwarf;

DWARFASTParserSwift::DWARFASTParserSwift(
TypeSystemSwiftTypeRef &swift_typesystem)
: m_swift_typesystem(swift_typesystem) {}
: DWARFASTParser(Kind::DWARFASTParserSwift),
m_swift_typesystem(swift_typesystem) {}

DWARFASTParserSwift::~DWARFASTParserSwift() {}

Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class DWARFASTParserSwift : public DWARFASTParser {
return lldb_private::ConstString();
}

static bool classof(const DWARFASTParser *Parser) {
return Parser->GetKind() == Kind::DWARFASTParserSwift;
}

protected:
lldb_private::TypeSystemSwiftTypeRef &m_swift_typesystem;
};
Expand Down