14 Commits

Author SHA1 Message Date
Ryosuke Niwa
e23e5705e6
[webkit.UncountedLambdaCapturesChecker] Ignore a lambda which gets called immediately (#162977)
Recognize more ways in which a lambda can be declared and called
immediately.
2025-12-12 14:58:38 -08:00
Ryosuke Niwa
aca48a44d1
Add the support for recognizing WTF::move like std::move (#170820)
This PR adds support for treating WTF::move like std::move in various
WebKit checkers.
2025-12-10 11:04:48 -08:00
Ryosuke Niwa
f9326ffb7e
[WebKit checkers] Treat a weak property / variable as safe (#163689)
Treat a weak Objective-C property, ivar, member variable, and local
variable as safe.
2025-12-09 12:28:22 -08:00
Ryosuke Niwa
c07d305718
[webkit.UncountedLambdaCapturesChecker] Add the support for WTF::ScopeExit and WTF::makeVisitor (#161926)
Lambda passed to WTF::ScopeExit / WTF::makeScopeExit and
WTF::makeVisitor should be ignored by the lambda captures checker so
long as its resulting object doesn't escape the current scope.

Unfortunately, recognizing this pattern generally is too hard to do so
directly hard-code these two function names to the checker.
2025-10-23 23:19:28 -07:00
Ryosuke Niwa
9d933c794a
[WebKit checkers] Add the support for OSObjectPtr (#159484)
Add the support for OSObjectPtr, which behaves like RetainPtr.
2025-09-18 21:46:22 -07:00
Ryosuke Niwa
725d9e8077
[webkit.UncountedLambdaCapturesChecker] Treat arguments of std::ranges::all_of as [[clang::noescape]] (#158419)
The checker already had std::ranges hard-coded to treat its arguments as
[[clang::oescape]] but the fact std::ranges::all_of is implemented as a
struct instead of a function confused the checker and resuled in a
superflous warning being emitted for std::ranges::all_of.

This PR adds the support for recognizing DeclRefExpr which appears as a
callee in VisitCallExpr and generalizes the check in
shouldTreatAllArgAsNoEscape to walk up the decl contexts to find the
target namespaces such as std::ranges:: or a namespace and a function
like WTF::switchOn.
2025-09-18 17:08:51 -07:00
Ryosuke Niwa
e1ca3d9376
[webkit.UncountedLambdaCapturesChecker] Ignore DeclRefExpr to a lambda in an no-escape argument (#155025)
Fix a bug that webkit.UncountedLambdaCapturesChecker was erroneously
emitting a warning for a DeclRefExpr which is passed in as an argument
to a no-escape function argument. The bug was caused by findLambdaInArg
not adding DeclRefExpr to the ignored set even when a lambda was
identified as an argument.
2025-09-09 13:46:39 -07:00
Kazu Hirata
8d49c64fa2
[StaticAnalyzer] Remove unused includes (NFC) (#141525)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-05-26 14:57:13 -07:00
Ryosuke Niwa
436504c3b9
[webkit.UncountedLambdaCapturesChecker] Treat every argument of std::ranges functions as noescape. (#138995)
Functions in std::ranges namespace does not store the lambada passed-in
as an arugment in heap so treat such an argument as if it has
[[noescape]] in the WebKit lambda capture checker so that we don't emit
warnings for capturing raw pointers or references to smart-pointer
capable objects.
2025-05-09 17:44:36 -07:00
Ryosuke Niwa
5d7e8ac53b
[webkit.UncountedLambdaCapturesChecker] Treat a copy capture of a CheckedPtr object as safe (#138068)
Allow copy capture of a reference to a CheckedPtr capable object since
such a capture will copy the said object instead of keeping a dangling
reference to the object.
2025-05-07 15:07:41 -07:00
Ryosuke Niwa
70e303f11e
[webkit.UncountedLambdaCapturesChecker] Treat a call to lambda function via a variable as safe. (#135688)
This PR makes the checker ignore a function call to lambda via a local
variable.
2025-04-24 17:10:05 -07:00
Ryosuke Niwa
2c31403f4f
[alpha.webkit.UnretainedLambdaCapturesChecker] Add the support for protectedSelf (#132518)
This PR adds the support for treating capturing of "self" as safe if the
lambda simultaneously captures "protectedSelf", which is a RetainPtr of
"self".

This PR also fixes a bug that the checker wasn't generating a warning
when "self" is implicitly captured. Note when "self" is implicitly
captured, we use the lambda's getBeginLoc as a fallback source location.
2025-04-09 11:52:36 -07:00
Ryosuke Niwa
8b093e5e17
[webkit.UncountedLambdaCapturesChecker] Recognize std::move(protectedThis) (#130925)
In WebKit, it's a common pattern for a lambda to capture "this" along
with "protectedThis" of Ref/RefPtr type, and re-capture "this" and
"std::move(protectedThis)" for a nested inner lambda. Recognize this
pattern and treat it as safe.
2025-03-12 10:23:46 -07:00
Ryosuke Niwa
5c3b05996f
[alpha.webkit.UnretainedLambdaCapturesChecker] Add a WebKit checker for lambda capturing NS or CF types. (#128651)
Add a new WebKit checker for checking that lambda captures of CF types
use RetainPtr either when ARC is disabled or enabled, and those of NS
types use RetainPtr when ARC is disabled.
2025-03-09 14:59:46 -07:00