This warning will trigger on loop variables that make copies in a range-based for-loop. The three cases this warning catches are:
- for (const Foo &x : Foos), where the range Foos does not return a copy. This warning will suggest using the non-reference type so the copy is obvious.
- for (const Foo x : Foos), where the range Foos does return a reference, but is copied into x. This warning will suggest using the reference type to prevent a copy from being made.
- for (const Bar &x : Foos), where Bar is constructed from Foo. In this case, suggest using the non-reference "const Bar" to indicate a copy is intended to be made, or "const Foo &" to prevent a copy from being made.
-Wrange-loop-analysis is being added as a sub-group to -Wloop-analysis. The previous warnings there are moved to -Wfor-loop-analysis. While the warnings are currently split along statement types, a finer grain division of warnings may be needed.
I think Alp's been trying to move to using an "isIgnored" function to do this test for some reason - I haven't looked into the motivation, but it might be something to check if you should be consistent with.