This is an archive of the discontinued LLVM Phabricator instance.

LLD: ELF: Remove partial class definitions of <Arch>LinkingContexts.
ClosedPublic

Authored by ruiu on Apr 1 2015, 9:45 PM.

Details

Reviewers
garious
Bigcheese
Summary

What we are doing in ELFTarget.h is dubious. In the file, we define
partial classes of <Arch>LinkingContexts to declare only a static member
function. We have different (complete) class definitions in other headers.
They would conflict if they exist in the same compilation unit (because
the ones defined in ELFTarget.h has only static member functions).
I don't think this is valid in C++.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 23117.Apr 1 2015, 9:45 PM
ruiu retitled this revision from to LLD: ELF: Remove partial class definitions of <Arch>LinkingContexts..
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added a reviewer: garious.
ruiu set the repository for this revision to rL LLVM.
ruiu added a project: lld.
ruiu added a subscriber: Unknown Object (MLST).

You're right - this is an ODR violation & your solution looks like it successfully corrects that.

(broader questions about an ideal architecture here - the design here seems a bit awkward - it's trying to avoid any one place including all of the FooLinkingContext.h but instead means we have a header that declares all the functions, so it loses the generality anyway. I'm not sure what a nice generalization would look like - there's always going to be some kind of "all the targets" registration point, likely)

ruiu added a comment.Apr 3 2015, 12:32 PM

We used to have a function containing if-else clause for each machine type to dispatch. And then it was replaced with this partial class implementation. Not sure which is better -- but I'll go with this patch for now to just convert invalid C++ code to valid code.

Bigcheese accepted this revision.Apr 6 2015, 3:45 PM
Bigcheese added a reviewer: Bigcheese.
Bigcheese added a subscriber: Bigcheese.

Thanks, the author of the original was supposed to fix this.

This revision is now accepted and ready to land.Apr 6 2015, 3:45 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r234039.