brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 4bdd153 Raw
43 lines · plain
1.. title:: clang-tidy - performance-move-const-arg2 3performance-move-const-arg4==========================5 6The check warns7 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 14In all three cases, the check will suggest a fix that removes the15``std::move()``.16 17Here 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 effect23 24  int x;25  return std::move(x);  // Warning: std::move of the variable of a trivially-copyable type has no effect26 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 happen30 31Options32-------33 34.. option:: CheckTriviallyCopyableMove35 36   If `true`, enables detection of trivially copyable types that do not37   have a move constructor. Default is `true`.38 39.. option:: CheckMoveToConstRef40 41   If `true`, enables detection of `std::move()` passed as a const42   reference argument. Default is `true`.43