[lld] r315418 - Rename CurAddressState -> Ctx.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 20 12:30:00 PDT 2017


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.

Cheers,
Rafael


More information about the llvm-commits mailing list