r330068 - [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
Malcolm Parsons via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 14 03:19:51 PDT 2018
On Sat, 14 Apr 2018, 04:22 Richard Trieu via cfe-commits, <
cfe-commits at lists.llvm.org> wrote:
> 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:
>
> // Load pending declaration chains.
> - for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
> - loadPendingDeclChain(PendingDeclChains[I].first,
> PendingDeclChains[I].second);
> + for (const auto &I : PendingDeclChains)
> + loadPendingDeclChain(I.first, I.second);
> PendingDeclChains.clear();
>
> 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.
>
Should clang-tidy handle this type of loop differently?
--
Malcolm Parsons
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180414/fe9a67bd/attachment.html>
More information about the cfe-commits
mailing list