[lld] r287938 - [ELF] Add explicit template instantiations for toString

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 08:59:49 PST 2016


This seems a bit esoteric/unusual compared to the norm for C++ in general
and the LLVM project in particular. Also requires maintenance of those
explicit instantiation lists, producing the kinds of problems you fixed
here.

Perhaps it could just roll the definitions into the header instead? (if the
separation is particularly important - the template definitions can be kept
in a separate section of the header from the declarations - but this isn't
done all that often either, in my experience)

On Tue, Nov 29, 2016 at 8:57 AM Evgeny Leviant <eleviant at accesssoftek.com>
wrote:

> I guess the main reason is source code readability (declarations and
> definitions are not mixed up).
> ------------------------------
> *От:* David Blaikie <dblaikie at gmail.com>
> *Отправлено:* 29 ноября 2016 г. 19:48
>
> *Кому:* Evgeny Leviant; llvm-commits at lists.llvm.org
> *Тема:* Re: [lld] r287938 - [ELF] Add explicit template instantiations
> for toString
> Ah, I'm a bit confused about what's going on in this file - could you help
> me understand why there are so many explicit template instantiations,
> rather than the usual expectation that templates are defined in the header
> and implicitly instantiated?
>
> Is there some particular issue with implicit instantiations that's being
> avoided here?
>
> On Mon, Nov 28, 2016 at 11:41 PM Evgeny Leviant <eleviant at accesssoftek.com>
> wrote:
>
> If you use toString<ELFT> *after* compiler sees the definition then no.
> ------------------------------
> *От:* David Blaikie <dblaikie at gmail.com>
> *Отправлено:* 28 ноября 2016 г. 21:24
>
> *Кому:* Evgeny Leviant; llvm-commits at lists.llvm.org
> *Тема:* Re: [lld] r287938 - [ELF] Add explicit template instantiations
> for toString
> Weird - wouldn't that have caused a failure at link time due to missing
> symbols?
>
> On Mon, Nov 28, 2016 at 10:14 AM Evgeny Leviant <eleviant at accesssoftek.com>
> wrote:
>
> They are defined in InputSection.h since r287787. They didn't have
> explicit instantiations initialy which, I guess, is because they weren't
> used anywhere, except InputSection.cpp.
> ------------------------------
> *От:* David Blaikie <dblaikie at gmail.com>
> *Отправлено:* 28 ноября 2016 г. 20:48
> *Кому:* Evgeny Leviant; llvm-commits at lists.llvm.org
> *Тема:* Re: [lld] r287938 - [ELF] Add explicit template instantiations
> for toString
>
> Are there extern template declarations in a header somewhere? (usually I'd
> expect to see them committed as a matched pair)
>
> On Fri, Nov 25, 2016 at 8:52 AM Eugene Leviant via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
> Author: evgeny777
> Date: Fri Nov 25 10:42:04 2016
> New Revision: 287938
>
> URL: http://llvm.org/viewvc/llvm-project?rev=287938&view=rev
> Log:
> [ELF] Add explicit template instantiations for toString
>
> Modified:
>     lld/trunk/ELF/InputSection.cpp
>
> Modified: lld/trunk/ELF/InputSection.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=287938&r1=287937&r2=287938&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/InputSection.cpp (original)
> +++ lld/trunk/ELF/InputSection.cpp Fri Nov 25 10:42:04 2016
> @@ -823,3 +823,8 @@ template class elf::MergeInputSection<EL
>  template class elf::MergeInputSection<ELF32BE>;
>  template class elf::MergeInputSection<ELF64LE>;
>  template class elf::MergeInputSection<ELF64BE>;
> +
> +template std::string elf::toString(const InputSectionBase<ELF32LE> *);
> +template std::string elf::toString(const InputSectionBase<ELF32BE> *);
> +template std::string elf::toString(const InputSectionBase<ELF64LE> *);
> +template std::string elf::toString(const InputSectionBase<ELF64BE> *);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161129/efce7c7d/attachment.html>


More information about the llvm-commits mailing list