[clang] [LifetimeSafety] Infer [[clang::lifetimebound]] annotation (PR #171081)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 8 03:15:21 PST 2025


================
@@ -160,6 +162,19 @@ class LifetimeChecker {
     for (const auto &[PVD, EscapeExpr] : AnnotationWarningsMap)
       Reporter->suggestAnnotation(PVD, EscapeExpr);
   }
+
+  void inferAnnotations() {
+    /// NOTE: This currently only adds the attribute to the function definition
+    /// being analyzed. For full inter-procedural inference to work reliably
+    /// (e.g., with out-of-order definitions), this attribute would also need to
+    /// be added to all other redeclarations of the function.
----------------
Xazax-hun wrote:

This is where the Clang static analyzer is doing some ordering over the function call graph: https://github.com/llvm/llvm-project/blob/405403c8ed4b2956dc03c270373fac2576a23a65/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp#L480



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


More information about the cfe-commits mailing list