Currently the range-for-copy incorrectly suggests changing a
by-value loop var to a reference to avoid copies even when:
(1) A converting constructor was used. Or,
(2) The argument to the copy constructor is not an lvalue.
For example:
for (const std::string sv : std::vector<const char*>{}) {
// warning:
// the loop variable's type is not a reference type;
// this creates a copy in each iteration;
// consider making this a reference
}
In these cases we can't actually avoid the copy, and reference
binding + lifetime extending a temporary is not a "fix" we should
be suggesting.
Admittedly, cases like the example should be fixed by the clang-tidy
user, but at minimum we need to be clearer about when a copy is made
and when a user defined conversion occurs (and that conversion may
be semantically important).
Formatting is off here, so run through clang-format?