[clang] [LifetimeSafety] Add report on misuse of clang::noescape (PR #177260)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 22 03:16:23 PST 2026


================
@@ -553,6 +553,12 @@ def LifetimeSafetySuggestions
     Lifetime annotation suggestions for function parameters that should be marked [[clang::lifetimebound]] based on lifetime analysis.
   }];
 }
+def LifetimeSafetyNoescape
+    : DiagGroup<"experimental-lifetime-safety-noescape"> {
+  code Documentation = [{
+    Detects misuse of [[clang::noescape]] annotation where the parameter escapes through return.
----------------
Xazax-hun wrote:

In the future, I think we will want to warn for escapes of other forms, like assigning to a member variable or to a global. I am OK with the documentation reflecting the current state rather than the future aspirations but wanted to call this out just in case anyone has strong feelings about this. 

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


More information about the cfe-commits mailing list