summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy/checks/performance-for-range-copy.rst
blob: d61df3fded2f4dd1ddbaa834991fbc4ff34f9794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
.. title:: clang-tidy - performance-for-range-copy

performance-for-range-copy
==========================

Finds C++11 for ranges where the loop variable is copied in each iteration but
it would suffice to obtain it by const reference.

The check is only applied to loop variables of types that are expensive to copy
which means they are not trivially copyable or have a non-trivial copy
constructor or destructor.

To ensure that it is safe to replace the copy with a const reference the
following heuristic is employed:

1. The loop variable is const qualified.
2. The loop variable is not const, but only const methods or operators are
   invoked on it, or it is used as const reference or value argument in
   constructors or function calls.
OpenPOWER on IntegriCloud