Bug 231954
| Summary: | clang-tidy checker to find places where WTFMove/std::move are missing with RetainPtr<> | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | David Kilzer (:ddkilzer) <ddkilzer> |
| Component: | Tools / Tests | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | darin, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=231814 | ||
David Kilzer (:ddkilzer)
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/84664132>