Skip to content

Commit b017b4c

Browse files
authored
[lldb][DWARF] Remove object_pointer from ParsedDWARFAttributes (#144880)
We can just always use `GetCXXObjectParameter` instead. We've only used this attribute to set the object parameter name on ClangASTMetadata, which doesn't seem like good enough justification to keep it around. Depends on #144879
1 parent 95c6c11 commit b017b4c

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,6 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {
445445
name.SetCString(form_value.AsCString());
446446
break;
447447

448-
case DW_AT_object_pointer:
449-
// GetAttributes follows DW_AT_specification.
450-
// DW_TAG_subprogram definitions and declarations may both
451-
// have a DW_AT_object_pointer. Don't overwrite the one
452-
// we parsed for the definition with the one from the declaration.
453-
if (!object_pointer.IsValid())
454-
object_pointer = form_value.Reference();
455-
break;
456-
457448
case DW_AT_signature:
458449
signature = form_value;
459450
break;
@@ -1116,7 +1107,7 @@ bool DWARFASTParserClang::ParseObjCMethod(
11161107
std::pair<bool, TypeSP> DWARFASTParserClang::ParseCXXMethod(
11171108
const DWARFDIE &die, CompilerType clang_type,
11181109
const ParsedDWARFTypeAttributes &attrs, const DWARFDIE &decl_ctx_die,
1119-
bool is_static, bool &ignore_containing_context) {
1110+
const DWARFDIE &object_parameter, bool &ignore_containing_context) {
11201111
Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
11211112
SymbolFileDWARF *dwarf = die.GetDWARF();
11221113
assert(dwarf);
@@ -1200,6 +1191,9 @@ std::pair<bool, TypeSP> DWARFASTParserClang::ParseCXXMethod(
12001191
TypeSystemClang::GetDeclContextForType(class_opaque_type), die,
12011192
attrs.name.GetCString());
12021193

1194+
// In DWARF, a C++ method is static if it has no object parameter child.
1195+
const bool is_static = !object_parameter.IsValid();
1196+
12031197
// We have a C++ member function with no children (this pointer!) and clang
12041198
// will get mad if we try and make a function that isn't well formed in the
12051199
// DWARF, so we will just skip it...
@@ -1225,9 +1219,7 @@ std::pair<bool, TypeSP> DWARFASTParserClang::ParseCXXMethod(
12251219
ClangASTMetadata metadata;
12261220
metadata.SetUserID(die.GetID());
12271221

1228-
char const *object_pointer_name =
1229-
attrs.object_pointer ? attrs.object_pointer.GetName() : nullptr;
1230-
if (object_pointer_name) {
1222+
if (char const *object_pointer_name = object_parameter.GetName()) {
12311223
metadata.SetObjectPtrName(object_pointer_name);
12321224
LLDB_LOGF(log, "Setting object pointer name: %s on method object %p.\n",
12331225
object_pointer_name, static_cast<void *>(cxx_method_decl));
@@ -1323,11 +1315,9 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
13231315
type_handled =
13241316
ParseObjCMethod(*objc_method, die, clang_type, attrs, is_variadic);
13251317
} else if (is_cxx_method) {
1326-
// In DWARF, a C++ method is static if it has no object parameter child.
1327-
const bool is_static = !object_parameter.IsValid();
13281318
auto [handled, type_sp] =
1329-
ParseCXXMethod(die, clang_type, attrs, decl_ctx_die, is_static,
1330-
ignore_containing_context);
1319+
ParseCXXMethod(die, clang_type, attrs, decl_ctx_die,
1320+
object_parameter, ignore_containing_context);
13311321
if (type_sp)
13321322
return type_sp;
13331323

@@ -1422,9 +1412,7 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
14221412
ClangASTMetadata metadata;
14231413
metadata.SetUserID(die.GetID());
14241414

1425-
char const *object_pointer_name =
1426-
attrs.object_pointer ? attrs.object_pointer.GetName() : nullptr;
1427-
if (object_pointer_name) {
1415+
if (char const *object_pointer_name = object_parameter.GetName()) {
14281416
metadata.SetObjectPtrName(object_pointer_name);
14291417
LLDB_LOGF(log,
14301418
"Setting object pointer name: %s on function "

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
470470
/// \param[in] decl_ctx_die The DIE representing the DeclContext of the C++
471471
/// method being parsed.
472472
///
473-
/// \param[in] is_static Is true iff we're parsing a static method.
473+
/// \param[in] object_parameter The DIE of this subprogram's object parameter.
474+
/// May be an invalid DIE for C++ static methods.
474475
///
475476
/// \param[out] ignore_containing_context Will get set to true if the caller
476477
/// should treat this C++ method as-if it was not a C++ method.
@@ -485,7 +486,8 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
485486
lldb_private::CompilerType clang_type,
486487
const ParsedDWARFTypeAttributes &attrs,
487488
const lldb_private::plugin::dwarf::DWARFDIE &decl_ctx_die,
488-
bool is_static, bool &ignore_containing_context);
489+
const lldb_private::plugin::dwarf::DWARFDIE &object_parameter,
490+
bool &ignore_containing_context);
489491

490492
lldb::TypeSP ParseArrayType(const lldb_private::plugin::dwarf::DWARFDIE &die,
491493
const ParsedDWARFTypeAttributes &attrs);
@@ -555,7 +557,6 @@ struct ParsedDWARFTypeAttributes {
555557
const char *mangled_name = nullptr;
556558
lldb_private::ConstString name;
557559
lldb_private::Declaration decl;
558-
lldb_private::plugin::dwarf::DWARFDIE object_pointer;
559560
lldb_private::plugin::dwarf::DWARFFormValue abstract_origin;
560561
lldb_private::plugin::dwarf::DWARFFormValue containing_type;
561562
lldb_private::plugin::dwarf::DWARFFormValue signature;

0 commit comments

Comments
 (0)