aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorRyosuke Niwa <rniwa@webkit.org>2024-11-12 09:46:28 -0800
committerGitHub <noreply@github.com>2024-11-12 09:46:28 -0800
commit2c6424e691e32f79bc303203deb1c91634d62286 (patch)
tree85bb2ada4c9288ce0519f2ff4218a4b38a5ffd18 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent06e08696248ac01754c87c22cc8a4b797ef46430 (diff)
downloadllvm-2c6424e691e32f79bc303203deb1c91634d62286.zip
llvm-2c6424e691e32f79bc303203deb1c91634d62286.tar.gz
llvm-2c6424e691e32f79bc303203deb1c91634d62286.tar.bz2
[webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]. (#114897)
This PR makes webkit.UncountedLambdaCapturesChecker ignore trivial functions as well as the one being passed to an argument with [[clang::noescape]] attribute. This dramatically reduces the false positive rate for this checker. To do this, this PR replaces VisitLambdaExpr in favor of checking lambdas via VisitDeclRefExpr and VisitCallExpr. The idea is that if a lambda is defined but never called or stored somewhere, then capturing whatever variable in such a lambda is harmless. VisitCallExpr explicitly looks for direct invocation of lambdas and registers its DeclRefExpr to be ignored in VisitDeclRefExpr. If a lambda is being passed to a function, it checks whether its argument is annotated with [[clang::noescape]]. If it's not annotated such, it checks captures for their safety. Because WTF::switchOn could not be annotated with [[clang::noescape]] as function type parameters are variadic template function so we hard-code this function into the checker. In order to check whether "this" pointer is ref-counted type or not, we override TraverseDecl and record the most recent method's declaration. In addition, this PR fixes a bug in isUnsafePtr that it was erroneously checking whether std::nullopt was returned by isUncounted and isUnchecked as opposed to the actual boolean value. Finally, this PR also converts the accompanying test to use -verify and adds a bunch of tests.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions