llvm-project
5cb9d767 - [WebKit checkers] Don't treat an indirect call as a mutation of a guardian (#242619)

Commit
1 day ago
[WebKit checkers] Don't treat an indirect call as a mutation of a guardian (#242619) The local variable checkers reported a raw pointer that is guarded by a local variable or parameter whenever the guarded scope contained a call without a direct callee, such as a call through a function pointer or a block, even when the guardian wasn't passed to the call. With fast enumeration, the guarded scope is the loop body: ```cpp if (auto *results = dynamic_objc_cast<NSArray>(dictionary[@"results"])) { for (id item in results) { if ([item isKindOfClass:PAL::getDDScannerResultClassSingleton()]) append((DDScannerResult *)item); } } ``` The element variable item was reported because the soft-linked class getter is a function pointer. The same happened with a block invocation such as a completion handler, or a call to a function pointer parameter. This accounted for seven false positives in WebKit. A call through a pointer to member function, such as (foo.*pmf)(), is also an indirect call. Its arguments are checked against the prototype of the member function pointer type, and its object is treated like the object of a regular member function call: the call mutates the guardian if the guardian is the object, unless the member function pointer is const-qualified. The object may also be the address of the guardian, as in (&foo->*pmf)(). Authored with Claude Code.
Author
Parents
Loading