-
Notifications
You must be signed in to change notification settings - Fork 37.7k
coins: Add move operations to Coin and CCoinsCacheEntry #30643
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
coins: Add move operations to Coin and CCoinsCacheEntry #30643
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30643. ReviewsSee the guideline for information on the review process. ConflictsNo conflicts as of last run. |
Don't we also need to add move constructor to |
They are mostly just a clang-tidy wrapper, so I wonder if there is a clang-tidy warning that can be used here instead. |
I have installed Sonar locally, reproduced the warning first, it doesn't appear anymore afer the change.
It seems to me that the Coin(CTxOut&& outIn, int nHeightIn, bool fCoinBaseIn) : out(std::move(outIn)), fCoinBase(fCoinBaseIn), nHeight(nHeightIn) {} The If you suspect I'm wrong here, let me know where you'd like me to investigate further. |
Can you add any relevant output to the PR description. |
I think what is being suggested here is to configure clang-tidy to produce this warning in our own CI instead of Sonar, which can then be shown to be fixed in this PR. I think that would be a more valuable change.
That would not be an explicit move constructor, right? That is a constructor that has one of its members moved in. An explicit move constructor would be
How can we be sure that this happens? |
A class has an implicitly-declared move constructor whenever:
(from https://en.cppreference.com/w/cpp/language/move_constructor) Personally, I find these rules too inscrutable to judge from a quick glance at a class, so if I want a class that is guaranteed to have a move constructor, I just add one explicitly: class Coin
{
...
Coin(Coin&&) noexcept = default;
...
}; |
530f1bd
to
d0f52dc
Compare
d0f52dc
to
945256d
Compare
The "coverage report" already has the Sonarcloud section - I have opened this issue because of the #28280 corecheck CI Sonar warnings. Or do you mean we should be able to reproduce this locally as well via
Done for |
I was mostly wondering about other cases, which would be nice to be able to find by clang-tidy, but that is probably only tangentially related to this pull. |
@maflcko |
945256d
to
5651525
Compare
cd400ac
to
db91623
Compare
Am I right in understanding that this PR's expected changes are:
And we are otherwise just explicitly declaring the move constructors that we expect to already be used implicitly in order to silence a spurious CI warning? Also, could you point me in the direction of reproducing this CI warning locally? I can't find the warning on corecheck (https://corecheck.dev/bitcoin/bitcoin/pulls/28280) |
Thanks for checking @davidgumberg!
I also had a hard time reproducing it on CI (sonarcould seems to have expired), but installed Sonar locally which gave the same warning before the change.
This is just a safety measure
Either that or adding a move constructor, since it's needed (regardless of whether it was there implicitly or not)
This was added to have an actual user of the (new?) move constructor |
db91623
to
263c83c
Compare
263c83c
to
f198344
Compare
Related to #28280 (comment), the CI build had a Sonar warning, namely:
Added defaulted move constructor and move assignment operator to
CCoinsCacheEntry
.Based on comments I've also added explicit special member functions to
Coin
.