Page MenuHomePhabricator

[ObjC][DWARF] Emit DW_AT_APPLE_objc_direct for methods marked as __attribute__((objc_direct))

Authored by teemperor on Dec 9 2019, 5:28 AM.



With DWARF5 it is no longer possible to distinguish normal methods and methods with __attribute__((objc_direct)) by just looking at the debug information
as they are both now children of the of the DW_TAG_structure_type that defines them (before only the __attribute__((objc_direct)) methods were children).

This means that in LLDB we are no longer able to create a correct Clang AST of a module by just looking at the debug information. Instead we would
need to call the Objective-C runtime to see which of the methods have a __attribute__((objc_direct)) and then add the attribute to our own Clang AST
depending on what the runtime returns. This would mean that we either let the module AST be dependent on the Objective-C runtime (which doesn't
seem right) or we retroactively add the missing attribute to the imported AST in our expressions.

A third option is to annotate methods with __attribute__((objc_direct)) as DW_AT_APPLE_objc_direct which is what this patch implements. This way
LLDB doesn't have to call the runtime for any __attribute__((objc_direct)) method and the AST in our module will already be correct when we create it.

Diff Detail

Event Timeline

teemperor created this revision.Dec 9 2019, 5:28 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 9 2019, 5:28 AM
aprantl added inline comments.Dec 9 2019, 5:07 PM

I think it would be good to leave a gap for here.
@SouraVX what's the latest plan for representing deleted/defaulted?


Could we make do in this test without all the ObjC metadata?


Please remove all quoted attributes, they cause trouble for maintaining the test in the future and usually aren't needed.

Looks pretty good, thanks!

teemperor updated this revision to Diff 233756.Dec 13 2019, 2:11 AM
  • Removed Objective-C metadata from LLVM test.
  • Removed quoted attributes.
  • Update DebugInfoFlags.def to be compatible with D68117 assuming probinson are applied there.
aprantl accepted this revision.Dec 13 2019, 2:43 PM


It would be nice to further manually reduce the IR testcase by stripping out any metadata that isn't needed. Otherwise this LGTM

This revision is now accepted and ready to land.Dec 13 2019, 2:43 PM
  • Further reduced test case.

Thanks. This is good to go!

This revision was automatically updated to reflect the committed changes.