[clang] [LifetimeSafety] Infer [[clang::lifetimebound]] annotation (PR #171081)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 8 01:23:45 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.
----------------
usx95 wrote:
I would skip mentioning inter-procedural inference as a single clang invocation can never achieve this. I would just mention the function analysis order for best results.
`// FIXME: To maximise inference propagation, functions should be analyzed in post-order of the call hierarchy, allowing inferred annotations to propagate through the call chain.`
For issue with redecl, I think we should have a separate fixme:
`// FIXME: Add the inferred attribute to all redeclarations of the function, not just the definition being analyzed.`
https://github.com/llvm/llvm-project/pull/171081
More information about the cfe-commits
mailing list