This is an archive of the discontinued LLVM Phabricator instance.

Change DT_* value definitions to macros in a separate file
ClosedPublic

Authored by arichardson on Mar 16 2018, 5:49 AM.

Details

Summary

I recently added a new dynamic tag to our fork of LLVM and when adding it
to llvm-readobj I noticed that not all DT_ values were being handled there.

Using macros in a .def file that can be included by both ELFDumper.cpp and
the ELF.h header ensures that the two don't get out of sync when new values
are added.

Diff Detail

Event Timeline

arichardson created this revision.Mar 16 2018, 5:49 AM

Use correct version of diff

This looks OK to me. Let's see what other reviewers think, my comments below.

include/llvm/BinaryFormat/DynamicTags.def
1

Excessive empty line.

8

I am not sure it is worth to mention the particular tool name here, as such file can be used for very different purposes I think.

tools/llvm-readobj/ELFDumper.cpp
1548

Personally to me one-line short form here and below looks easier to read:

#define HEXAGON_DYNAMIC_TAG(name, value) case DT_##name: return #name;
1569

This undef should be right after the end of the first switch I think.

1582

This looks to be dead now.

espindola accepted this revision.Mar 19 2018, 1:02 PM

I agree with George's comments, but LGTM otherwise.

This revision is now accepted and ready to land.Mar 19 2018, 1:02 PM
arichardson marked 4 inline comments as done.

Address review comments

include/llvm/BinaryFormat/DynamicTags.def
1

I did this for consistency with ElfRelocs/X86_64.def which also adds a newline here. Happy to remove it though since I also think it looks a bit strange.

It seems all the files in that folder except AMDGPU.def and BPF.def have that newline.

tools/llvm-readobj/ELFDumper.cpp
1548

This is what git-clang-format did to the file but I agree the short version is easier to understand. Fixed.

grimar accepted this revision.Mar 20 2018, 3:04 AM

LGTM

tools/llvm-readobj/ELFDumper.cpp
1548

Ah :( We probably should go with formatted version then.
That's unfortunate.

espindola accepted this revision.Mar 20 2018, 10:13 AM

LGTM, but do use the git-clang-formated version.

This revision was automatically updated to reflect the committed changes.