<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 5, 2017 at 8:38 AM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Apr 4, 2017 at 10:55 PM, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br>
> On Tue, Apr 4, 2017 at 10:23 PM, Davide Italiano <<a href="mailto:davide@freebsd.org">davide@freebsd.org</a>> wrote:<br>
>><br>
>> On Tue, Apr 4, 2017 at 10:06 PM, Rui Ueyama via llvm-commits<br>
>> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>> > Author: ruiu<br>
>> > Date: Wed Apr  5 00:06:17 2017<br>
>> > New Revision: 299511<br>
>> ><br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=299511&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=299511&view=rev</a><br>
>> > Log:<br>
>> > Simplify. NFC.<br>
>> ><br>
>> > A for-loop is more boring than a find_if, but I think this is easier to<br>
>> > read.<br>
>> ><br>
>> > Modified:<br>
>> >     lld/trunk/ELF/LinkerScript.cpp<br>
>> ><br>
>> > Modified: lld/trunk/ELF/LinkerScript.cpp<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=299511&r1=299510&r2=299511&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>LinkerScript.cpp?rev=299511&<wbr>r1=299510&r2=299511&view=diff</a><br>
>> ><br>
>> > ==============================<wbr>==============================<wbr>==================<br>
>> > --- lld/trunk/ELF/LinkerScript.cpp (original)<br>
>> > +++ lld/trunk/ELF/LinkerScript.cpp Wed Apr  5 00:06:17 2017<br>
>> > @@ -923,10 +923,12 @@ std::vector<PhdrEntry> LinkerScript::cre<br>
>> >  bool LinkerScript::<wbr>ignoreInterpSection() {<br>
>> >    // Ignore .interp section in case we have PHDRS specification<br>
>> >    // and PT_INTERP isn't listed.<br>
>> > -  return !Opt.PhdrsCommands.empty() &&<br>
>> > -         llvm::find_if(Opt.<wbr>PhdrsCommands, [](const PhdrsCommand &Cmd) {<br>
>> > -           return Cmd.Type == PT_INTERP;<br>
>> > -         }) == Opt.PhdrsCommands.end();<br>
>> > +  if (Opt.PhdrsCommands.empty())<br>
>> > +    return false;<br>
>> > +  for (PhdrsCommand &Cmd : Opt.PhdrsCommands)<br>
>> > +    if (Cmd.Type == PT_INTERP)<br>
>> > +      return false;<br>
>> > +  return true;<br>
>> >  }<br>
>> ><br>
>><br>
>> Maybe the `find_if` construct was too obscure, but now that you split<br>
>> the first `if` out, you may consider replacing the phdrs command loop<br>
>> with `all_of`, which I think it's an improvement in readability. I<br>
>> don't feel strong about it tho, up to you.<br>
><br>
><br>
> You still need to use `find_if` instead of `all_of`, no?<br>
<br>
</div></div>I don't think you need `find_if` (unless I'm reading the code wrong,<br>
which could be possible). I originally thought you needed to check<br>
universality while you need non-existence, so none_of is what you<br>
 want.<br>
<br>
diff --git a/ELF/LinkerScript.cpp b/ELF/LinkerScript.cpp<br>
index 924a0f3..22073c8 100644<br>
--- a/ELF/LinkerScript.cpp<br>
+++ b/ELF/LinkerScript.cpp<br>
@@ -859,10 +859,8 @@ bool LinkerScript::<wbr>ignoreInterpSection() {<br>
<span class="">   // and PT_INTERP isn't listed.<br>
</span>   if (Opt.PhdrsCommands.empty())<br>
     return false;<br>
-  for (PhdrsCommand &Cmd : Opt.PhdrsCommands)<br>
-    if (Cmd.Type == PT_INTERP)<br>
-      return false;<br>
-  return true;<br>
+  return llvm::none_of(Opt.<wbr>PhdrsCommands,<br>
+                       [](PhdrsCommand &Cmd) { return Cmd.Type ==<br>
PT_INTERP; });<br>
 }<br></blockquote><div> </div><div>Ah. But I think I'd still prefer the for-loop version, although it's not a strong preference.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 uint32_t LinkerScript::getFiller(<wbr>StringRef Name) {<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
--<br>
Davide<br>
<br>
"There are no solved problems; there are only problems that are more<br>
or less solved" -- Henri Poincare<br>
</div></div></blockquote></div><br></div></div>