Bug 306787
| Summary: | check-webkit-style: add checker for protect() in variable initialization | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | David Kilzer (:ddkilzer) <ddkilzer> |
| Component: | Tools / Tests | Assignee: | David Kilzer (:ddkilzer) <ddkilzer> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
David Kilzer (:ddkilzer)
The check-webkit-style tool should warn about using `protect()` free function when assigning to RefPtr/Ref variables, which violates SaferCPP guidelines.
Bad patterns that should trigger warnings:
```cpp
auto foo = protect(m_foo);
RefPtr bar = protect(foo());
if (RefPtr client = protect(client()))
```
Good patterns that should NOT trigger warnings:
```cpp
protect(foo)->doSomething(); // Method chaining - valid use
someFunction(protect(foo)); // Function argument - valid use
return protect(m_foo); // Return value - valid use
```
See also: <https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines#do-not-call-protect-free-function-to-initialize-local-variables>
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/169460205>
David Kilzer (:ddkilzer)
Pull request: https://github.com/WebKit/WebKit/pull/57712
EWS
Committed 306771@main (3fa54a20c8ad): <https://commits.webkit.org/306771@main>
Reviewed commits have been landed. Closing PR #57712 and removing active labels.