NEW231954
clang-tidy checker to find places where WTFMove/std::move are missing with RetainPtr<>
https://bugs.webkit.org/show_bug.cgi?id=231954
Summary clang-tidy checker to find places where WTFMove/std::move are missing with Re...
David Kilzer (:ddkilzer)
Reported 2021-10-19 08:18:08 PDT
clang-tidy checker to find places where WTFMove/std::move are missing with RetainPtr<>. In Bug 231814 Comment #6 and Bug 231814 Comment #11, I reimplemented a suggestion from Darin, but I missed adding a WTFMove() of a RetainPtr<> object that was going out of scope, resulting in some ref count churn: RetainPtr<SecKeyRef> LocalConnection::createCredentialPrivateKey(...) { RetainPtr privateKeyAttributes = @{ ... }; if (context) { auto mutableCopy = adoptNS([privateKeyAttributes mutableCopy]); mutableCopy.get()[(id)kSecUseAuthenticationContext] = context; privateKeyAttributes = mutableCopy; // FIXME: Missing WTFMove(mutableCopy) } [...] } A clang-tidy checker would be useful that warns about a missing WTFMove/std::move where a RetainPtr<> object is last referenced in a block/function using an assignment operator to another RetainPtr<> variable. I'm sure there are more of these cases in WebKit, and such a checker could probably be made generic enough for any class with an operator=(&&) implementation.
Attachments
Radar WebKit Bug Importer
Comment 1 2021-10-26 08:19:16 PDT
Note You need to log in before you can comment on or make changes to this bug.