<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 1, 2016 at 6:29 PM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Mon Feb  1 20:29:03 2016<br>
New Revision: 259455<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=259455&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=259455&view=rev</a><br>
Log:<br>
Replace auto with the real type.<br>
<br>
Modified:<br>
    lld/trunk/ELF/OutputSections.cpp<br>
<br>
Modified: lld/trunk/ELF/OutputSections.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259455&r1=259454&r2=259455&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259455&r1=259454&r2=259455&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/OutputSections.cpp (original)<br>
+++ lld/trunk/ELF/OutputSections.cpp Mon Feb  1 20:29:03 2016<br>
@@ -144,7 +144,7 @@ template <class ELFT> void GotSection<EL<br>
<br>
 template <class ELFT> void GotSection<ELFT>::writeTo(uint8_t *Buf) {<br>
   Target->writeGotHeader(Buf);<br>
-  for (const auto &L : MipsLocalGotPos) {<br>
+  for (std::pair<uintX_t, size_t> &L : MipsLocalGotPos) {<br></blockquote><div><br></div><div>This is probably accidentally causing a copy, because the value type of a map is usually std::pair<const K, V> - so this sort of for loop introduces an implicit conversion and then causes local reference extension to occur (Clang has a warning for this - so I hope this is triggering a warning)<br><br>This is one of the reasons auto is particularly encouraged in places like this - to avoid the possibility of mismatching with the type (though Clang's warning makes this a less risky proposition)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     uint8_t *Entry = Buf + L.second * sizeof(uintX_t);<br>
     write<uintX_t, ELFT::TargetEndianness, sizeof(uintX_t)>(Entry, L.first);<br>
   }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>