Qt-RangeLoopReference

Finds places where you’re using C++11 range-loops with non-trivial types by value

Required inputs: IR

Finds places where you're using C++11 range-loops with non-trivial types by value although you don't want the copy-ctor and dtor being called.

Fix it by adding a missing const-& or & (if the range declaration is already const).

Example

for (const auto &i : list) { ... }

The notion of "trivial" here is slightly weaker than "C++ trivially copyable". Assignment operators and move-ctors are disregarded. A "non-trivial" type in this sense has at least one non-trivial copy-ctor or dtor and thus is also no "C++ trivial class"

This rule is based on clazy rule range-loop-reference

Possible Messages

Key

Text

Severity

Disabled

range_loop_reference

Missing{} reference in range-for with non-trivial type “{}”.

None

False

Options

level

level : int = 1

Importance level of the rule as given for clazy. 0 is most desirable, higher values fall off in quality.