Debian Codegraph @

llvm-project/clang-tools-extra/docs/clang-tidy/checks/performance/move-const-arg.rst

raw
1 .. title:: clang-tidy - performance-move-const-arg
2
3 performance-move-const-arg
4 ==========================
5
6 The check warns
7
8 - if ``std::move()`` is called with a constant argument,
9
10 - if ``std::move()`` is called with an argument of a trivially-copyable type,
11
12 - if the result of ``std::move()`` is passed as a const reference argument.
13
14 In all three cases, the check will suggest a fix that removes the
15 ``std::move()``.
16
17 Here are examples of each of the three cases:
18
19 .. code-block:: c++
20
21 const string s;
22 return std::move(s); // Warning: std::move of the const variable has no effect
23
24 int x;
25 return std::move(x); // Warning: std::move of the variable of a trivially-copyable type has no effect
26
27 void f(const string &s);
28 string s;
29 f(std::move(s)); // Warning: passing result of std::move as a const reference argument; no move will actually happen
30
31 Options
32 -------
33
34 .. option:: CheckTriviallyCopyableMove
35
36 If `true`, enables detection of trivially copyable types that do not
37 have a move constructor. Default is `true`.
38
39 .. option:: CheckMoveToConstRef
40
41 If `true`, enables detection of `std::move()` passed as a const
42 reference argument. Default is `true`.