Issue |
91568
|
Summary |
[clang-tidy] performance-unnecessary-value-param provide invalid hint for class with deleted move constructor
|
Labels |
clang-tidy,
false-positive
|
Assignees |
|
Reporter |
PiotrZSL
|
Example:
```
#include <optional>
struct Some
{
Some();
Some(const Some&);
Some(Some&&) = delete;
};
struct Other
{
Other(std::optional<Some> some)
: some(std::move(some))
{
}
std::optional<Some> some;
};
```
Produces:
- <source>:13:31: warning: the parameter 'some' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
- <source>:14:14: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
But when removing std::move:
- <source>:14:14: warning: parameter 'some' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
In such case, check suggest developer to add std::move, but when actually moving it, other check says that's not valid.
For classes with deleted move constructor check should not suggest to use std::move.
Bug looks to be in:
- utils::type_traits::hasNonTrivialMoveConstructor
- utils::type_traits::hasNonTrivialMoveAssignment
as those functions do not check if constructor is deleted.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs