================
@@ -85,11 +79,43 @@ untouched:
};
+Pass-by-value in function bodies
+---------------------------------
+
+Replaces ``const T&`` function parameters that are unconditionally copied into
+a local variable with pass-by-value and ``std::move()``. This applies to free
+functions, member functions, and constructors (for copies in the body rather
+than the initializer list).
+
+.. code-block:: c++
+
+ #include <string>
+
+ -void process(const std::string &S) {
+ - std::string Local = S;
+ +void process(std::string S) {
+ + std::string Local = std::move(S);
+ // use Local...
+ }
+
+The check only triggers when:
+
+- The parameter type is a non-trivially-copyable class or struct.
+- The type has a non-deleted move constructor.
+- The parameter is used exactly once (in the copy).
+- There is no overload taking an rvalue reference for the same parameter.
+
+.. note::
+
+ This transformation is not applied when ``ValuesOnly`` is set to `true`,
+ or in dependent (template) contexts.
----------------
EugeneZelenko wrote:
```suggestion
This transformation is not applied when :option:`ValuesOnly` is set to
`true`, or in dependent (template) contexts.
```
https://github.com/llvm/llvm-project/pull/182024
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits