This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFC] Remove redundant accessibility heuristic in the DWARF parser
ClosedPublic

Authored by teemperor on Jul 6 2021, 12:57 AM.

Details

Summary

LLDB's DWARF parser has some heuristics for guessing and fixing up the accessibility
of C++ class/struct members after they were already created in the internal Clang AST.
The heuristic is that if a struct/class has a base class, then it's actually a class and it's
members are private unless otherwise specified.

From what I can see this heuristic isn't sound and also unnecessary. The idea that inheritance
implies that the class keyword was used and the default visibility is private is
incorrect. Also both GCC and Clang use DW_TAG_structure_type and DW_TAG_class_type
for struct and class types respectively, so the default visibility we infer from that
information is always correct and there is no need to fix it up.

And finally, the access specifiers we set in the Clang AST are anyway unused within LLDB.
The expression parser explicitly ignores them to give users access to private members
and there is not SBAPI functionality that exposes this information.

This patch removes all this code for the reasons above. This should be NFC.

Diff Detail

Event Timeline

teemperor created this revision.Jul 6 2021, 12:57 AM
teemperor requested review of this revision.Jul 6 2021, 12:57 AM
werat accepted this revision.Jul 6 2021, 2:23 AM

Given that the access modifiers are not used by LLDB and none of the tests fail because of this cleanup, looks good to me :)

This revision is now accepted and ready to land.Jul 6 2021, 2:23 AM
shafik added a comment.Jul 7 2021, 4:58 PM

So it is not obvious to me looking at these changes, are we just removing code that gets access wrong or are we removing all setting of access?

I was look at clang Sema code and it does use access to make some decisions and sometimes asserts, it is not obvious to me if we can hit these caeses through expression parsing though.

This revision was landed with ongoing or failed builds.Jul 22 2021, 4:36 AM
This revision was automatically updated to reflect the committed changes.