brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · d740984 Raw
38 lines · plain
1.. title:: clang-tidy - performance-for-range-copy2 3performance-for-range-copy4==========================5 6Finds C++11 for ranges where the loop variable is copied in each iteration but7it would suffice to obtain it by const reference.8 9The check is only applied to loop variables of types that are expensive to copy10which means they are not trivially copyable or have a non-trivial copy11constructor or destructor.12 13To ensure that it is safe to replace the copy with a const reference the14following heuristic is employed:15 161. The loop variable is const qualified.172. The loop variable is not const, but only const methods or operators are18   invoked on it, or it is used as const reference or value argument in19   constructors or function calls.20 21Options22-------23 24.. option:: WarnOnAllAutoCopies25 26   When `true`, warns on any use of ``auto`` as the type of the range-based for27   loop variable. Default is `false`.28 29.. option:: AllowedTypes30 31   A semicolon-separated list of names of types allowed to be copied in each32   iteration. Regular expressions are accepted, e.g. ``[Rr]ef(erence)?$``33   matches every type with suffix ``Ref``, ``ref``, ``Reference`` and34   ``reference``. The default is empty. If a name in the list contains the35   sequence `::`, it is matched against the qualified type name36   (i.e. ``namespace::Type``), otherwise it is matched against only the37   type name (i.e. ``Type``).38