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.

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?

- Kim

Den lör 14 apr. 2018 12:20Malcolm Parsons via cfe-commits <> skrev:

> On Sat, 14 Apr 2018, 04:22 Richard Trieu via cfe-commits, <
>> 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 mailing list

Reply via email to