This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

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.Feb 13 2020, 4:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2020, 4:37 AM
Herald added a subscriber: rupprecht. · View Herald Transcript
grimar marked an inline comment as done.Feb 13 2020, 5:48 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
5737

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.Feb 14 2020, 2:00 AM
  • Addressed my previous comment.
This revision is now accepted and ready to land.Feb 14 2020, 3:01 AM
MaskRay accepted this revision.Feb 14 2020, 9:43 PM
MaskRay added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
1068

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.