-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed #12384 - removed misleading suggestion from passedByValue
and iterateByValue
messages
#7205
base: main
Are you sure you want to change the base?
Conversation
… `iterateByValue` messages
Just stating the fact is probably not enough to steer users in the right direction. And if 'pass by value + move' is used, the object will still be passed by value. |
Putting a short summary of the solutions in the verbose message would make sense. I have some changes which already adjusted some way too verbose messages. So the |
There is just too many possible solutions to include it at all. So no verbose message at all would be better. Maybe we can just reword the message by including the term "unnecessary copy" which would also be closer to the |
thanks for clarifying this message it's needed. 👍
Sounds good.
stupid question; what do you mean with 'universal ref'?
sorry are there that many possible solutions? how about this verbose message:
The option "make it non-const and always use std::move when function is called" feels less generic to me. It can work in specific cases but in general if the function is designed to be for arbitrary usage then const reference is still preferable right? |
on top of the mentioned ones:
Any additional information will be just misleading and I would rather just have the most informative message about what was detected. The compilers/analyzers are also only provide fixits if there is only a single solution. |
Maybe we can reword that somehow so it indicates that it's not a exhaustive list of all possible solutions. But only some suggestions how it can be solved. I think those suggestions can help the user to choose the optimal solution. Personally I feel that your other suggestions are a bit related to the std::move suggestion.
I would think that we can make the output more specific. A proper fixit is helpful. For this code:
Since "value" is not copied in this function, as far as I know it makes sense to suggest that "value" is made a const reference in this code. And clang-tidy also suggests making it a reference. For a setter method that copy the parameter somehow, it might be a better idea to move.. it's unfortunate to explicitly recommend making it a const reference as we do now.. for information clang-tidy still suggests to make the parameter a const reference. |
Basically passing an |
That would need additional logic to determine what the suggestion might be and that might not be 100%. Another problem with making any suggestions is that beside the implementation you also need to take all callers into consideration. Example: The problem is also with clang-tidy: llvm/llvm-project#57908. Then there is the lack of detection of unnecessary copies/missing And more related stuff: |
No description provided.