-
Notifications
You must be signed in to change notification settings - Fork 273
Wrap local vars in std::move (Clang 7 build fix) #3239
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
Wrap local vars in std::move (Clang 7 build fix) #3239
Conversation
This commit fixes diffblue#3238, a warning emitted by clang 7.0: ``` java_bytecode_convert_method.cpp:2924:10: error: local variable 'block' will be copied despite being returned by name [-Werror,-Wreturn-std-move] return block; ^~~~~ java_bytecode_convert_method.cpp:2924:10: note: call 'std::move' explicitly to avoid copying return block; ^~~~~ std::move(block) ``` The fix is to wrap all such returned local variables in a call to std::move().
Did you arrive at this particular list of return sites by a regex or similar match, or is this exactly equal to the places where Clang 7 complains? |
It is exactly equal to the places where Clang 7 complains. I don't think a simple regex could deal with this, it's context-sensitive, the variables need to be local. |
Great -- it sounds like we're not adding this in cases where return-value optimisation would apply in that case. |
Yes, this is a pretty cool warning. I'm not sure who is in charge of the CI, but perhaps it's worth adding Clang 7 at some point? I don't mind posting PRs for any more of these that people introduce in the meantime, if nobody else is using Clang 7 yet, but it might be worth doing at some point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 72bfc35).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89432202
This commit fixes #3238, a warning emitted by clang 7.0:
The fix is to wrap all such returned local variables in a call to
std::move().