[clang] [WebKit checkers] Trivial function analysis ignores some nodelete annotation (PR #183970)
Ryosuke Niwa via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 2 10:58:58 PST 2026
================
@@ -454,10 +454,29 @@ bool isPtrConversion(const FunctionDecl *F) {
return false;
}
-bool isNoDeleteFunction(const FunctionDecl *F) {
+static bool isNoDeleteFunctionDecl(const FunctionDecl *F) {
return typeAnnotationForReturnType(F) == WebKitAnnotation::NoDelete;
}
+bool isNoDeleteFunction(const FunctionDecl *F) {
+ if (llvm::any_of(F->redecls(), isNoDeleteFunctionDecl))
+ return true;
+
+ const auto *MD = dyn_cast<CXXMethodDecl>(F);
+ if (!MD || !MD->isVirtual())
+ return false;
+
+ auto Overriders = llvm::to_vector(MD->overridden_methods());
+ while (!Overriders.empty()) {
+ const auto *Fn = Overriders.pop_back_val();
+ llvm::append_range(Overriders, Fn->overridden_methods());
+ if (isNoDeleteFunctionDecl(Fn))
+ return true;
+ }
+
+ return false;
----------------
rniwa wrote:
We do! It looks like we don't have a test coverage for that so I'll add one
https://github.com/llvm/llvm-project/pull/183970
More information about the cfe-commits
mailing list