On Sat, 14 Apr 2018, 04:22 Richard Trieu via cfe-commits, < cfe-commits@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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits