llvm / llvm/llvm-project

[clang-tidy] performance-move-const-arg CheckTriviallyCopyableMove warns where there is no performance impact

Open
#204,111 1 comment 1 reaction 0 assignees View on GitHub
clang-tidy enhancement
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`std::move` on a trivially copyable type to construct or assign the rvalue to another instance results in a plain copy, just as-if the `std::move` wasn't there at all. How is this warning meant to help improve performance?

I'd rather see code where `std::move` is consistently used to show _intent_. Those "moves" also helps when redefining types. If we remove these moves, we'll have to add them back later in case the types later becomes cheaper to move than to copy.

* I suggest moving the `CheckTriviallyCopyableMove` option away from `performance-move-const-arg`.
Motivation: It doesn't have anything to do with moving a `const` arg.

* I suggest moving `CheckTriviallyCopyableMove` completely out of `performance-*`.
Motivation: Removing the `std::move`s don't improve performance.

* I suggest disabling `CheckTriviallyCopyableMove` by default.
Motivation: It's highly arguable that it promotes writing code where the intent is clear. I argue that it does the opposite.

Contributor guide

Open the contributing guide

Research direction

Start by reading the clang-tidy performance-move-const-arg check, especially the CheckTriviallyCopyableMove option and its current diagnostic behavior. First resolve whether the option should be renamed, moved, or disabled by default; done means the selected policy is implemented and the check's user-visible behavior and configuration are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.