An addition to the move-constructor-init check was duplicating the
modernize-pass-by-value check.
Remove the additional check and UseCERTSemantics option.
Run the move-constructor-init test with both checks enabled.
Fix modernize-pass-by-value false-positive when initializing a base
class.
Add option to modernize-pass-by-value to only warn about parameters
that are already values.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Is the modernize-pass-by-value check configurable in a way to only trigger when copied constructor arguments are not moved?
I think our use case has been to have move-constructor-init check enabled to catch cases that can be optimized but not trigger on every constructor that uses const& instead of value + move, i.e. modernizing is not prescribed, but catching cases where the argument is already passed by value and making them faster is desirable.
I think this meets my needs for the cert-oop11-cpp check as it appears to be preserving the original behavior. If a user has the UseCERTSemantics option set in one of their scripts, that appears to be silently accepted and discarded currently, so I don't think this will break anyone's build scripts.
The downside has more to do with the categorization. Not everyone enables "modernize", which is now the only place to be told about a possible correctness issue that misc-move-constructor-init was previously reporting. (This part of the check is one half modernization, one half performance, and one half correctness, depending on which lens you view the code through.) I don't think that's a huge downside, however.
This change should definitely be called out in the release notes.
The performance part should be handled by performance-unnecessary-value-param.
It should warn in this situation, but not create a fix that would conflict with modernize-pass-by-value's fix.
LG.
Yep, I think so.
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp | ||
---|---|---|
1 | Test for one check running a different check is somewhat confusing. If we need to ensure that the patterns the two checks target don't overlap, maybe we should rename the test (<check1>+<check2>.cpp or something like that)? |
D28022 changes performance-unnecessary-value-param so that it handles this part of modernize-pass-by-value.
So this isn't the end of the story here yet.
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp | ||
---|---|---|
1 | Doing it like this was to show that no functionality was lost, not that there's no overlap. |
Test for one check running a different check is somewhat confusing. If we need to ensure that the patterns the two checks target don't overlap, maybe we should rename the test (<check1>+<check2>.cpp or something like that)?