- Avoid converting loops that iterate over the size of a container and don't use its elements, as this would result in an unused-result warning.
- Never capture the elements by value on lambdas, thus avoiding doing unnecessary copies and errors with non-copyable types.
- The 'const auto &' instead of 'auto &' substitution on const containers now works on arrays and pseudoarrays as well.
- The error about multiple replacements in the same macro call is now documented in the tests (not solved though).
- Due to [1], I had to add a dummy usage of the range element (like "(void) *It;" or similars) on the tests that had empty loops.
- I removed the braces from the CHECK comments. I think that there is no need for them, and they confuse vim.
Details
Diff Detail
Event Timeline
clang-tidy/modernize/LoopConvertCheck.cpp | ||
---|---|---|
457–458 | I'd call that 'Usage' here, as it's not an iterator. | |
459–464 | We need to document the members of Usage better: It seems unclear why the 'else' part goes into a lambda capture, or why in the if() path adding a '.' will ever help. Examples would help in comments here, I think. | |
clang-tidy/modernize/LoopConvertUtils.cpp | ||
765–769 | This needs to be a comment at the IsArrow field of Usage. | |
test/clang-tidy/modernize-loop-convert-basic.cpp | ||
504 | why Pseudo? |
clang-tidy/modernize/LoopConvertUtils.cpp | ||
---|---|---|
765–769 | I think when the comment is on the Usage member, it's fine to delete it here, as it'll only get out of sync. | |
clang-tidy/modernize/LoopConvertUtils.h | ||
223–226 | I think this now really needs a different name, or we should put it into an enum if we can't find a good bool name that fits both the lambda capture and member expression case. |
Comment the enumerators.
Do we need default?
I think so. We need to set the cases that do not fall in any of these categories to something, and I think that using one of the other three as the default kind would be confusing. But maybe there is a better name than just UK_Default. Any ideas?
Can we perhaps just add a couple of example of other cases that are not member expressions? With that, LG.
I'd call that 'Usage' here, as it's not an iterator.