[clang] [webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]. (PR #114897)
Rashmi Mudduluru via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 11 11:34:22 PST 2024
================
@@ -89,7 +182,25 @@ class UncountedLambdaCapturesChecker
}
printQuotedQualifiedName(Os, Capture.getCapturedVar());
- Os << " to uncounted type is unsafe.";
+ Os << " to ref-counted / CheckedPtr capable type is unsafe.";
+
+ PathDiagnosticLocation BSLoc(Capture.getLocation(), BR->getSourceManager());
+ auto Report = std::make_unique<BasicBugReport>(Bug, Os.str(), BSLoc);
+ BR->emitReport(std::move(Report));
+ }
+
+ void reportBugOnThisPtr(const LambdaCapture &Capture) const {
+ SmallString<100> Buf;
+ llvm::raw_svector_ostream Os(Buf);
+
+ if (Capture.isExplicit()) {
+ Os << "Captured ";
+ } else {
+ Os << "Implicitly captured ";
+ }
+
+ Os << "raw-pointer 'this' to ref-counted / CheckedPtr capable type is "
----------------
t-rasmud wrote:
nit: Can this warning be better worded? `.. ref-counted (or CheckedPtr capable) type ...`? Or anything else that conveys that it's unsafe to capture raw-pointer to a ref-counted type or a "CheckedPtr capable" type.
https://github.com/llvm/llvm-project/pull/114897
More information about the cfe-commits
mailing list