Page MenuHomePhabricator

[llvm-readobj] - Refactor the code that dumps relocations.

Authored by grimar on Thu, Feb 13, 4:37 AM.



The current code has following issues:

  1. It has a duplicated logic part.
  2. This logic relies on unwrapOrError calls, but if we want to convert them to warnings, we will need to change all of them what is hard to do because of the duplication.

In this patch I've created a new method that returns Expected<> what allows
now to catch all errors in a single place and remove the code duplication.

Note: this change is itself a refactor NFC. It does not change the current logic
anyhow. It prepares the code for the follow-up(s).

Diff Detail

Event Timeline

grimar created this revision.Thu, Feb 13, 4:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Feb 13, 4:37 AM
Herald added a subscriber: rupprecht. · View Herald Transcript
grimar marked an inline comment as done.Thu, Feb 13, 5:48 AM
grimar added inline comments.

I've realized that Sym variable is not used for LLVMStyle.
(And a warning was not reported because of std::tie it seems).
Will update diff after finishing with the follow-up patch for this one.

grimar updated this revision to Diff 244595.Fri, Feb 14, 2:00 AM
  • Addressed my previous comment.
This revision is now accepted and ready to land.Fri, Feb 14, 3:01 AM
MaskRay accepted this revision.Fri, Feb 14, 9:43 PM
MaskRay added inline comments.

Add a comment about what this if block does.

The st_name field of a STT_SECTION is usually 0 (empty string). This code block returns the section name.

This revision was automatically updated to reflect the committed changes.