diff options
author | Ryosuke Niwa <rniwa@webkit.org> | 2025-02-14 16:33:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-14 16:33:34 -0800 |
commit | 77041da98932f77896d48366703d956ae7a82036 (patch) | |
tree | 73a8c4ca1ed3172e397574b1b4579883063eb5e0 /llvm/lib/Analysis/LazyCallGraph.cpp | |
parent | 60af83506a3aa379c59e0f9793ce7815d726aee1 (diff) | |
download | llvm-77041da98932f77896d48366703d956ae7a82036.zip llvm-77041da98932f77896d48366703d956ae7a82036.tar.gz llvm-77041da98932f77896d48366703d956ae7a82036.tar.bz2 |
[webkit.UncountedLambdaCapturesChecker] Recognize nested protectedThis pattern (#126443)
In WebKit, it's pretty common to capture "this" and "protectedThis"
where "protectedThis" is a guardian variable of type Ref or RefPtr for
"this". Furthermore, it's common for this "protectedThis" variable from
being passed to an inner lambda by std::move. Recognize this pattern so
that we don't emit warnings for nested inner lambdas.
To recognize this pattern, we introduce a new DenseSet,
ProtectedThisDecls, which contains every "protectedThis" we've
recognized to our subclass of DynamicRecursiveASTVisitor. This set is
now populated in "hasProtectedThis" and "declProtectsThis" uses this
DenseSet to determine a given value declaration constitutes a
"protectedThis" pattern or not.
Because hasProtectedThis and declProtectsThis had to be moved from the
checker class to the visitor class, it's now a responsibility of each
caller of visitLambdaExpr to check whether a given lambda captures
"this" without a "protectedThis" or not.
Finally, this PR improves the code to recognize "protectedThis" pattern
by allowing more nested CXXBindTemporaryExpr, CXXOperatorCallExpr, and
UnaryOperator expressions.
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
0 files changed, 0 insertions, 0 deletions