[clang] [WebKit checkers] Trivial function analysis ignores some nodelete annotation (PR #183970)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 1 12:06:00 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))
----------------
steakhal wrote:

What made me think of this was the following:
When would I want to check for the nodelete annotation without walking all of the redecls?
If the answer is that in some cases I would want to only check a specific declaration - then it makes sense to have an API for inspecting that.
If you always want to check all of its redeclarations, then why have a separate API for doing that? Opening up the opportunity for accidentally using that while you intended to implicitly check all the redecls.

https://github.com/llvm/llvm-project/pull/183970


More information about the cfe-commits mailing list