Skip to content

[lldb][DWARFASTParserClang] Make GetCXXObjectParameter public and call it from unit-tests #144879

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 3 commits into from
Jun 19, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ static bool TagIsRecordType(dw_tag_t tag) {
/// a default DWARFDIE. If \c containing_decl_ctx is not a valid
/// C++ declaration context for class methods, assume no object
/// parameter exists for the given \c subprogram.
static DWARFDIE GetCXXObjectParameter(const DWARFDIE &subprogram,
const DWARFDIE &decl_ctx_die) {
DWARFDIE
DWARFASTParserClang::GetCXXObjectParameter(const DWARFDIE &subprogram,
const DWARFDIE &decl_ctx_die) {
assert(subprogram);
assert(subprogram.Tag() == DW_TAG_subprogram ||
subprogram.Tag() == DW_TAG_inlined_subroutine ||
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 @@ -112,6 +112,10 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
void MapDeclDIEToDefDIE(const lldb_private::plugin::dwarf::DWARFDIE &decl_die,
const lldb_private::plugin::dwarf::DWARFDIE &def_die);

lldb_private::plugin::dwarf::DWARFDIE GetCXXObjectParameter(
const lldb_private::plugin::dwarf::DWARFDIE &subprogram,
const lldb_private::plugin::dwarf::DWARFDIE &decl_ctx_die);

protected:
/// Protected typedefs and members.
/// @{
Expand Down
38 changes: 26 additions & 12 deletions lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,18 +889,32 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) {
ASSERT_TRUE(context_die.IsValid());
ASSERT_EQ(context_die.Tag(), DW_TAG_structure_type);

auto subprogram_definition = context_die.GetSibling();
ASSERT_TRUE(subprogram_definition.IsValid());
ASSERT_EQ(subprogram_definition.Tag(), DW_TAG_subprogram);
ASSERT_FALSE(subprogram_definition.GetAttributeValueAsOptionalUnsigned(
DW_AT_external));

auto param_die = subprogram_definition.GetFirstChild();
ASSERT_TRUE(param_die.IsValid());

ParsedDWARFTypeAttributes attrs(subprogram_definition);
EXPECT_TRUE(attrs.object_pointer.IsValid());
EXPECT_EQ(attrs.object_pointer, param_die);
{
auto decl_die = context_die.GetFirstChild();
ASSERT_TRUE(decl_die.IsValid());
ASSERT_EQ(decl_die.Tag(), DW_TAG_subprogram);
ASSERT_TRUE(decl_die.GetAttributeValueAsOptionalUnsigned(DW_AT_external));

auto param_die = decl_die.GetFirstChild();
ASSERT_TRUE(param_die.IsValid());

EXPECT_EQ(param_die,
ast_parser.GetCXXObjectParameter(decl_die, context_die));
}

{
auto subprogram_definition = context_die.GetSibling();
ASSERT_TRUE(subprogram_definition.IsValid());
ASSERT_EQ(subprogram_definition.Tag(), DW_TAG_subprogram);
ASSERT_FALSE(subprogram_definition.GetAttributeValueAsOptionalUnsigned(
DW_AT_external));

auto param_die = subprogram_definition.GetFirstChild();
ASSERT_TRUE(param_die.IsValid());

EXPECT_EQ(param_die, ast_parser.GetCXXObjectParameter(subprogram_definition,
context_die));
}
}

TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) {
Expand Down
Loading