Skip to content

Commit 8775119

Browse files
authored
Revert "[lldb][DWARF] Remove object_pointer from ParsedDWARFAttributes" (llvm#145065)
Reverts llvm#144880 Caused `TestObjCIvarsInBlocks.py` to fail on macOS CI.
1 parent bfef873 commit 8775119

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,15 @@ 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+
448457
case DW_AT_signature:
449458
signature = form_value;
450459
break;
@@ -1107,7 +1116,7 @@ bool DWARFASTParserClang::ParseObjCMethod(
11071116
std::pair<bool, TypeSP> DWARFASTParserClang::ParseCXXMethod(
11081117
const DWARFDIE &die, CompilerType clang_type,
11091118
const ParsedDWARFTypeAttributes &attrs, const DWARFDIE &decl_ctx_die,
1110-
const DWARFDIE &object_parameter, bool &ignore_containing_context) {
1119+
bool is_static, bool &ignore_containing_context) {
11111120
Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
11121121
SymbolFileDWARF *dwarf = die.GetDWARF();
11131122
assert(dwarf);
@@ -1191,9 +1200,6 @@ std::pair<bool, TypeSP> DWARFASTParserClang::ParseCXXMethod(
11911200
TypeSystemClang::GetDeclContextForType(class_opaque_type), die,
11921201
attrs.name.GetCString());
11931202

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

1222-
if (char const *object_pointer_name = object_parameter.GetName()) {
1228+
char const *object_pointer_name =
1229+
attrs.object_pointer ? attrs.object_pointer.GetName() : nullptr;
1230+
if (object_pointer_name) {
12231231
metadata.SetObjectPtrName(object_pointer_name);
12241232
LLDB_LOGF(log, "Setting object pointer name: %s on method object %p.\n",
12251233
object_pointer_name, static_cast<void *>(cxx_method_decl));
@@ -1315,9 +1323,11 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
13151323
type_handled =
13161324
ParseObjCMethod(*objc_method, die, clang_type, attrs, is_variadic);
13171325
} 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();
13181328
auto [handled, type_sp] =
1319-
ParseCXXMethod(die, clang_type, attrs, decl_ctx_die,
1320-
object_parameter, ignore_containing_context);
1329+
ParseCXXMethod(die, clang_type, attrs, decl_ctx_die, is_static,
1330+
ignore_containing_context);
13211331
if (type_sp)
13221332
return type_sp;
13231333

@@ -1412,7 +1422,9 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
14121422
ClangASTMetadata metadata;
14131423
metadata.SetUserID(die.GetID());
14141424

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

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,7 @@ 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] object_parameter The DIE of this subprogram's object parameter.
474-
/// May be an invalid DIE for C++ static methods.
473+
/// \param[in] is_static Is true iff we're parsing a static method.
475474
///
476475
/// \param[out] ignore_containing_context Will get set to true if the caller
477476
/// should treat this C++ method as-if it was not a C++ method.
@@ -486,8 +485,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
486485
lldb_private::CompilerType clang_type,
487486
const ParsedDWARFTypeAttributes &attrs,
488487
const lldb_private::plugin::dwarf::DWARFDIE &decl_ctx_die,
489-
const lldb_private::plugin::dwarf::DWARFDIE &object_parameter,
490-
bool &ignore_containing_context);
488+
bool is_static, bool &ignore_containing_context);
491489

492490
lldb::TypeSP ParseArrayType(const lldb_private::plugin::dwarf::DWARFDIE &die,
493491
const ParsedDWARFTypeAttributes &attrs);
@@ -557,6 +555,7 @@ struct ParsedDWARFTypeAttributes {
557555
const char *mangled_name = nullptr;
558556
lldb_private::ConstString name;
559557
lldb_private::Declaration decl;
558+
lldb_private::plugin::dwarf::DWARFDIE object_pointer;
560559
lldb_private::plugin::dwarf::DWARFFormValue abstract_origin;
561560
lldb_private::plugin::dwarf::DWARFFormValue containing_type;
562561
lldb_private::plugin::dwarf::DWARFFormValue signature;

0 commit comments

Comments
 (0)