This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Split ParseSingleMember into Obj-C property and normal member/ivar parsing code.
ClosedPublic

Authored by teemperor on Oct 12 2021, 4:44 AM.

Details

Summary

Right now DWARFASTParserClang::ParseSingleMember has two parts: One part parses Objective-C properties
and the other part parses C/C++ members/Objective-C ivars. These parts are pretty much independent
of each other (with one historical exception, see below) and in practice they parse DIEs with different tags/attributes:
DW_TAG_APPLE_property and DW_TAG_member.

I don't see a good reason for keeping the different parsing code intertwined in a single function, so instead split
out the Objective-C property parser into its own function.

Note that 90% of this commit is just unindenting nearly all of ParseSingleMember which was inside a
if (tag == DW_TAG_member) block. I.e., think of the old ParseSingleMember function as: The rest is
just moving the property parsing code into its own function and I added the ReportError implementation
in case we fail to resolve the property type (which before was just a silent failure).

void DWARFASTParserClang::ParseSingleMember(...) {
  [...]
  if (tag == DW_TAG_member) {
    [...] // This huge block got unindented in this patch as the `if` above is gone.
  }
  if (property) {
    [...] // This is the property parsing code that is now its own function.
  }
}

There is one exception to the rule that the parsers are independent. Before 2012 Objective-C properties were encoded as DW_TAG_member
with DW_AT_APPLE_property* attributes describing the property. In 2012 this has changed in a series of commits (see for example
c0449635b35b057c5a877343b0c5f14506c7cf02 which updates the docs) so that DW_TAG_APPLE_property is now used for properties.
With the old format we first created an ivar and afterwards used the DW_AT_APPLE_property* attributes to create the respective
property, but there doesn't seem to be any way to create such debug info with any clang from the last 9 years. So this is technically not NFC
in case some finds debug info from that time and tries to use properties.

Diff Detail

Event Timeline

teemperor created this revision.Oct 12 2021, 4:44 AM
teemperor requested review of this revision.Oct 12 2021, 4:44 AM
teemperor edited the summary of this revision. (Show Details)
teemperor edited the summary of this revision. (Show Details)Oct 12 2021, 4:48 AM

I plan to make this (and the other functions) return actual Errors but at least for now this patch is just doing the normal DWARF parser error handling (= logging and returning).

aprantl accepted this revision.Oct 15 2021, 11:20 AM
aprantl added inline comments.
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
2651

if (!propAttrs.prop_name)

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

typo: contain

This revision is now accepted and ready to land.Oct 15 2021, 11:20 AM