<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64930>64930</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] performance-unnecessary-value-param false positive
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ferdinandhubbard981
      </td>
    </tr>
</table>

<pre>
    #### description
```cpp
#include <iostream>
#include <string>

std::string concatenateStrings(std::string baseString, std::string extraString) {
    baseString += std::move(extraString); // if extraString was a const reference, this line would involve an unnecessary copy.
    return baseString;
}
```

The reason to pass ```extraString``` by value is to potentially avoid a copy. If the caller has a ```std::string``` that they no longer need, they can ```std::move``` it into the function, and inside the function, we can move the data from it into ```baseString```

Here's an example of the above scenario:
```cpp
int main() {
    std::string str1 = "Hello, ";
    std::string str2 = "world!";

    std::string result = concatenateStrings(str1, std::move(str2));

    std::cout << result << std::endl;

    return 0;
}
```

#### clang-tidy command
```sh
clang-tidy -checks=""-*,performance-unnecessary-value-param example.cpp
```

#### expected clang-tidy output
no warnings

#### actual clang-tidy output
```
warning: the parameter 'extraString' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
std::string concatenateStrings(std::string baseString, std::string extraString) {
 ^
 const      &
```

[full example with clang-tidy output in compiler explorer](https://godbolt.org/z/MfEhzWa69)

#### How to fix
##### easy solution
By not outputting the warning if there is a std::move called on the parameter

##### difficult solution (not sure if possible)
checking if the std::move is redundant or not


I am working on a patch to this issue.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VkuT6jgP_TVmo4IKDq8sWDRwqb6Lb_VN1awVWyGe69gpP6C5v37K5k03M72arlS6sKyjY_lICnqvdoZoyaYrNt0MMIbWumVDTiqDRraxrtHJajEe1FYel4yX1wckeeFUH5Q1rNiw4o3NitMj-v68wktlhI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