<div dir="auto">That would be a nice outcome of all the "run-tools-on-llvm" changes if any problems were filed as bugs on the tools. We have a number of them filed on iwyu, and they make for nice, concrete bugs to troubleshoot even if we don't always know how to fix them. <div dir="auto"><br></div><div dir="auto">For this specific clang-tidy issue, do you have any ideas for how to tell this loop apart from any other? I'm guessing the container is modified while iterating... Or do you mean skip all non-iterator loops? </div><div dir="auto"><br></div><div dir="auto">- Kim </div></div><br><div class="gmail_quote"><div dir="ltr">Den lör 14 apr. 2018 12:20Malcolm Parsons via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> skrev:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><div class="gmail_quote"><div dir="ltr">On Sat, 14 Apr 2018, 04:22 Richard Trieu via cfe-commits, <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I was tracking down a similar issue to the lldb issue before noticing the change was reverted.  The bad change that lead to it is:<br><div><br></div><div><div>     // Load pending declaration chains.</div><div>-    for (unsigned I = 0; I != PendingDeclChains.size(); ++I)</div><div>-      loadPendingDeclChain(PendingDeclChains[I].first, PendingDeclChains[I].second);</div><div>+    for (const auto &I : PendingDeclChains)</div><div>+      loadPendingDeclChain(I.first, I.second);</div><div>     PendingDeclChains.clear();</div></div><div><br></div><div>Although the two looks like similar, the vector PendingDeclChains is a class member and gets new elements during loop runs.  Once enough elements are added to the vector, it get reallocated to a larger memory, but the loop is still trying to process the old, now freed, memory.  Using an index and checking the size every loop is the right way to process this vector.</div></div><div class="gmail_quote"><div dir="ltr"></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Should clang-tidy handle this type of loop differently?</div><div dir="auto"><br style="font-family:sans-serif"><div data-smartmail="gmail_signature" style="font-family:sans-serif" dir="auto">-- <br>Malcolm Parsons</div></div></div>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>