[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.
Felix Berger via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 12 07:28:43 PST 2020
flx added a comment.
In D90042#2391246 <https://reviews.llvm.org/D90042#2391246>, @aaron.ballman wrote:
> In D90042#2390203 <https://reviews.llvm.org/D90042#2390203>, @flx wrote:
>
>> Thanks for the suggestion, I had never hear of creduce!
>
> Glad to have introduced you to it -- it's a great tool!
>
>> After a bit of trial an error I seem to have found a more minimal example:
>>
>> namespace std {
>> template <typename> class function;
>> template <typename a, typename... b> class function<a(b...)> {
>> public:
>> void operator()(b...);
>> };
>> } // namespace std
>> struct c {
>> c();
>> c(const c &);
>> };
>> std::function<void(c &)> f;
>> void d() {
>> c Orig;
>> c Copy = Orig;
>> f(Copy);
>> }
>>
>>
>> To be frank I can't spot a meaningful difference to the std::function copy we already have.
>
> Aha, I may have spotted it. The call operators have subtly different signatures and the signature we have in our test file is wrong. Note the `&&` in our test file compared to what the standard defines: http://eel.is/c++draft/func.wrap.func#inv which is what's causing the difference here: https://godbolt.org/z/hxfM7P
Ah! That is subtle and surprising, but makes sense. I confirmed that the new test cases fail now before the fix is put in place. Thanks for your help!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90042/new/
https://reviews.llvm.org/D90042
More information about the cfe-commits
mailing list