This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][NFCI] Refactor DWARFAbbreviationDeclaration::extract
ClosedPublic

Authored by bulbazord on May 15 2023, 1:27 PM.

Details

Summary

The motivation behind this refactor is to be able to use
DWARFAbbreviationDeclaration from LLDB. LLDB has its own implementation
of DWARFAbbreviationDeclaration that is very similar to LLVM's but it
has different semantics around error handling.

This patch modifies llvm::DWARFAbbreviationDeclaration::extract to
return an llvm::Expected<ExtractState> to differentiate between "I am
done extracting" and "An error has occured", something which the current
return type (bool) does not accurately capture.

Diff Detail

Event Timeline

bulbazord created this revision.May 15 2023, 1:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2023, 1:27 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
bulbazord requested review of this revision.May 15 2023, 1:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2023, 1:27 PM
aprantl accepted this revision.May 15 2023, 1:51 PM
This revision is now accepted and ready to land.May 15 2023, 1:51 PM
rastogishubham accepted this revision.May 15 2023, 1:53 PM
rastogishubham added a subscriber: rastogishubham.

Just a small comment, but otherwise LGTM

jhenderson added inline comments.May 16 2023, 1:01 AM
llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
50

(ignore this suggestion if this isn't going to end up as a user-facing error)

There are guidelines on error and warning formatting (see https://llvm.org/docs/CodingStandards.html#error-and-warning-messages), so we should conform to those in new code, unless there's a strong reason not to.

77

Same as above.

129–130

Same as above.

bulbazord added inline comments.May 16 2023, 9:21 AM
llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
50

Thanks for pointing that out. They will be user-facing from LLDB (and possibly from LLVM tools in the future), so I'll update this.

bulbazord updated this revision to Diff 522666.May 16 2023, 9:28 AM

Update error message formatting to conform to LLVM's error messaging guidelines

bulbazord marked 3 inline comments as done.May 16 2023, 9:29 AM
This revision was landed with ongoing or failed builds.May 16 2023, 12:55 PM
This revision was automatically updated to reflect the committed changes.