<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Mar 6, 2018 at 10:31 AM Rafael Avila de Espindola <<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Rui Ueyama via Phabricator via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> writes:<br>
<br>
> ruiu added inline comments.<br>
><br>
><br>
> ================<br>
> Comment at: ELF/InputSection.h:347<br>
><br>
> -std::string toString(const elf::InputSectionBase *);<br>
> +std::string toString(const elf::InputSectionBase *, uint64_t SecOffset = 0);<br>
>  } // namespace lld<br>
> ----------------<br>
> I don't think this is a good idea. lld::toString(T) is an overloaded function dispatched by its parameter type. But you are now defining a different function which you only use in MapFile.cpp. I'd move this back to the original file.<br>
<br>
My objection to the original implementation was that it was looking at<br>
the output of toString, effectively knowing exactly what toString does<br>
and breaking the modularity.<br>
<br>
Would you be OK with having<br>
<br>
std::string lld::someName(const InputSectionBase *Sec, uint64_t Offset);<br>
<br>
and implementing std::string lld::toString(const InputSectionBase *Sec)<br>
as someName(Sec, 0)?<br></blockquote><div><br></div><div> I'm lukewarm on that. To me, toString(T) is a stringize function for an object of type T, and passing an additional information other than the object itself is a deviation from that principle, as the given additional information is not a part of the given object. If we need that in too many places, I might change my mind, but at least for this patch I don't want to do that.</div></div></div>