[PATCH] D16864: ELF: Make Out<ELFT> initialization less error-prone.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 15:06:25 PST 2016
On Thu, Feb 4, 2016 at 3:04 PM, Rafael EspĂndola <rafael.espindola at gmail.com
> wrote:
> On 4 February 2016 at 17:59, Rui Ueyama <ruiu at google.com> wrote:
> > ruiu added a comment.
> >
> > OK to commit?
> >
> >
> > ================
> > Comment at: ELF/Writer.cpp:120
> > @@ +119,3 @@
> > +
> > + std::unique_ptr<GnuHashTableSection<ELFT>> GnuHashTab;
> > + std::unique_ptr<GotPltSection<ELFT>> GotPlt;
> > ----------------
> > rafael wrote:
> >> Why do these need to be std::uinque_ptr?
> > Because we want to release the object at end of this function. (Does
> this answer to your question?)
>
>
> What I meant was why use
>
> std::unique_ptr<GnuHashTableSection<ELFT>> GnuHashTab;
> ...
> if (Config->GnuHash)
> GnuHashTab.reset(new GnuHashTableSection<ELFT>);
> ...
> Out<ELFT>::GnuHashTab = GnuHashTab.get();
>
> instead of
>
> GnuHashTableSection<ELFT> GnuHashTab;
> ...
> Out<ELFT>::GnuHashTab = Config->GnuHash ? &GnuHashTab : nullptr;
>
That would create GnuHashTab whether it's going to be used or not, which
I'd like to avoid.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160204/50488e96/attachment.html>
More information about the llvm-commits
mailing list