This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Rename SyntheticSection::empty to more appropriate isNeeded() with opposite meaning
ClosedPublic

Authored by MaskRay on Mar 29 2019, 12:35 AM.

Details

Summary

Some synthetic sections can be empty while still being needed, thus they
can't be removed by removeUnusedSyntheticSections(). Rename this member
function to more appropriate isNeeded() with the opposite meaning.

No functional change intended.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Mar 29 2019, 12:35 AM
grimar added a subscriber: grimar.Mar 29 2019, 1:47 AM

I think renaming makes sense.
I also can imagine a different wording in this renaming: empty() -> used().
Not sure what is better though.

I think renaming makes sense.
I also can imagine a different wording in this renaming: empty() -> used().
Not sure what is better though.

I did struggle with the choice between used() and needed() :) I chose needed() as I think needed is slightly stronger: used in a way that requires it to exist. As a non-native English speaker my interpretation may be inaccurate and I am open to other suggestions :)

grimar added a comment.EditedMar 29 2019, 2:34 AM

As a non-native English speaker my interpretation may be inaccurate and I am open to other suggestions :)

We need a help then :) I added @jhenderson, hopefully, he has an opinion about what can be better here.

As a non-native English speaker my interpretation may be inaccurate and I am open to other suggestions :)

We need a help then :) I added @jhenderson, hopefully, he has an opinion about what can be better here.

Thanks 😆

I think I like needed() more than used(), but either is probably valid. "needed" implies it is required, and is independent of its usage, which I think is probably the desired semantics (you could of course just use required instead, but needed is fine). - I could imagine an architecture where it is important to create specific synthetic section regardless of anything else in the ELF (e.g. nothing else might actually use that section within the link). By the way, since you're changing from empty(), whose name mirrors a common function name in the standard libraries, to something that isn't, you should probably make it into a verb phrase (i.e. isNeeded()), based on they style guide.

MaskRay updated this revision to Diff 192799.Mar 29 2019, 3:52 AM
MaskRay retitled this revision from [ELF] Rename SyntheticSection::empty to more appropriate needed() with opposite meaning to [ELF] Rename SyntheticSection::empty to more appropriate isNeeded() with opposite meaning.
MaskRay edited the summary of this revision. (Show Details)

Adopt jhenderson's suggestion: needed -> isNeeded

ruiu accepted this revision.Apr 1 2019, 1:04 AM

LGTM

I think this renaming makes sense.

This revision is now accepted and ready to land.Apr 1 2019, 1:04 AM
This revision was automatically updated to reflect the committed changes.