[lld] r315418 - Rename CurAddressState -> Ctx.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 22 20:01:54 PDT 2017


On Fri, Oct 20, 2017 at 12:30 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:
>
> > Author: ruiu
> > Date: Tue Oct 10 19:45:54 2017
> > New Revision: 315418
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=315418&view=rev
> > Log:
> > Rename CurAddressState -> Ctx.
> >
> > We used CurAddressState to capture a dynamic context just like
> > we use lambdas to capture static contexts. So, CurAddressState
> > is used everywhere in LinkerScript.cpp. It is worth a shorter
> > name.
>
> This change does more than a rename. In particular:
>
> > Modified: lld/trunk/ELF/LinkerScript.h
> > URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> LinkerScript.h?rev=315418&r1=315417&r2=315418&view=diff
> > ============================================================
> ==================
> > --- lld/trunk/ELF/LinkerScript.h (original)
> > +++ lld/trunk/ELF/LinkerScript.h Tue Oct 10 19:45:54 2017
> > @@ -218,7 +218,7 @@ class LinkerScript final {
> >    void output(InputSection *Sec);
> >    void process(BaseCommand &Base);
> >
> > -  AddressState *CurAddressState = nullptr;
> > +  std::unique_ptr<AddressState> Ctx;
> >    OutputSection *Aether;
>
> Why have you changed this? The objective of having a *local*
> std::unique_ptr<AddressState> was to make sure it would always be freed
> on function return.
>
> Now if we forget to set Ctx to nullptr we will have a valid pointer
> longer than desired.
>

I thought that explicitly resetting a unique_ptr to nullptr is better than
leaving a dangling pointer, but I'm okay in either way. If you feel that
the original way is better, feel free to make that change.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171022/dfb856fa/attachment.html>


More information about the llvm-commits mailing list