This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Merge LinkerScript::addSymbol and declareSymbol
AbandonedPublic

Authored by MaskRay on Mar 30 2019, 7:03 AM.

Details

Summary

To factor out the common part.

Event Timeline

MaskRay created this revision.Mar 30 2019, 7:03 AM
ruiu added a comment.Apr 1 2019, 12:27 AM

I'm not sure if this is an improvement. Sometimes, I actually like separating functions even if the separated functions have some amount of common code. It's like writing documents in a natural language -- sometimes you want to repeat the same thing in two different paragraphs to make it easier to understand. It feels to me that this is that kind of situation.

Sometimes, I actually like separating functions even if the separated functions have some amount of common code.

I agree with this point: making duplication if it helps readability. And I noticed that rLLD357373 was the recent interpretation of this rule. I did think over before creating this, and i think it slightly improves readability.

IMHO, after merging, the common/different parts are emphasized and it stops a reader from asking "what the two functions have in common and what are their differences?" (I asked myself this question while reading it because the shared parts are not too trivial: if (!shouldDefineSym(Cmd)), uint8_t Visibility = Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT;, replaceSymbol<Defined> and the different choices of placeholder st_value).

MaskRay abandoned this revision.Jul 28 2020, 9:01 AM