[clang] Add nodelete annotation for WebKit checkers (PR #177839)

Ryosuke Niwa via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 26 16:01:03 PST 2026


================
@@ -508,6 +508,17 @@ class TrivialFunctionAnalysisVisitor
     if (auto *FnDecl = dyn_cast<FunctionDecl>(D)) {
       if (FnDecl->isVirtualAsWritten())
         return false;
+      auto ReturnType = FnDecl->getReturnType();
+      if (auto *Type = ReturnType.getTypePtrOrNull()) {
+        if (auto *AttrType = dyn_cast<AttributedType>(Type)) {
+          if (auto *Attr = AttrType->getAttr()) {
+            if (auto *AnnotateType = dyn_cast<AnnotateTypeAttr>(Attr)) {
+              if (AnnotateType->getAnnotation() == "webkit.nodelete")
+                return true;
+            }
+          }
+        }
+      }
----------------
rniwa wrote:

Makes sense. Adopted that approach.

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


More information about the cfe-commits mailing list