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

Endre Fülöp via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 26 04:54:42 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;
+            }
+          }
+        }
+      }
----------------
gamesh411 wrote:

We could use some of the helpers to make it less nested:

```suggestion
auto ReturnType = FnDecl->getReturnType();
if (auto *AttrType = dyn_cast_or_null<AttributedType>(ReturnType.getTypePtrOrNull())) {
  if (auto *AnnotateType = dyn_cast_or_null<AnnotateTypeAttr>(AttrType->getAttr())) {
    if (AnnotateType->getAnnotation() == "webkit.nodelete")
      return true;
  }
}
```

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


More information about the cfe-commits mailing list