[lld] r307039 - [ELF] - Simplify allocateHeaders(). NFC.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 10:49:35 PDT 2017


Nice!

Do you need the llvm:: prefix?

Cheers,
Rafael

George Rimar via llvm-commits <llvm-commits at lists.llvm.org> writes:

> Author: grimar
> Date: Mon Jul  3 09:05:51 2017
> New Revision: 307039
>
> URL: http://llvm.org/viewvc/llvm-project?rev=307039&view=rev
> Log:
> [ELF] - Simplify allocateHeaders(). NFC.
>
> * Return type changed to void, because it was unused.
> * std::find_if -> llvm::find_if
>
> Modified:
>     lld/trunk/ELF/LinkerScript.cpp
>
> Modified: lld/trunk/ELF/LinkerScript.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=307039&r1=307038&r2=307039&view=diff
> ==============================================================================
> --- lld/trunk/ELF/LinkerScript.cpp (original)
> +++ lld/trunk/ELF/LinkerScript.cpp Mon Jul  3 09:05:51 2017
> @@ -784,22 +784,21 @@ void LinkerScript::processNonSectionComm
>    }
>  }
>  
> -static bool
> +static void
>  allocateHeaders(std::vector<PhdrEntry> &Phdrs,
>                  ArrayRef<OutputSectionCommand *> OutputSectionCommands,
>                  uint64_t Min) {
> -  auto FirstPTLoad =
> -      std::find_if(Phdrs.begin(), Phdrs.end(),
> -                   [](const PhdrEntry &E) { return E.p_type == PT_LOAD; });
> +  auto FirstPTLoad = llvm::find_if(
> +      Phdrs, [](const PhdrEntry &E) { return E.p_type == PT_LOAD; });
>    if (FirstPTLoad == Phdrs.end())
> -    return false;
> +    return;
>  
>    uint64_t HeaderSize = getHeaderSize();
>    if (HeaderSize <= Min || Script->hasPhdrsCommands()) {
>      Min = alignDown(Min - HeaderSize, Config->MaxPageSize);
>      Out::ElfHeader->Addr = Min;
>      Out::ProgramHeaders->Addr = Min + Out::ElfHeader->Size;
> -    return true;
> +    return;
>    }
>  
>    assert(FirstPTLoad->First == Out::ElfHeader);
> @@ -822,12 +821,10 @@ allocateHeaders(std::vector<PhdrEntry> &
>      Phdrs.erase(FirstPTLoad);
>    }
>  
> -  auto PhdrI = std::find_if(Phdrs.begin(), Phdrs.end(), [](const PhdrEntry &E) {
> -    return E.p_type == PT_PHDR;
> -  });
> +  auto PhdrI = llvm::find_if(
> +      Phdrs, [](const PhdrEntry &E) { return E.p_type == PT_PHDR; });
>    if (PhdrI != Phdrs.end())
>      Phdrs.erase(PhdrI);
> -  return false;
>  }
>  
>  void LinkerScript::assignAddresses(std::vector<PhdrEntry> &Phdrs) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list