[clang] [LifetimeSafety] Run analysis in post-order of CallGraph for better annotation propagation (PR #174178)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 15 00:46:00 PST 2026
================
@@ -194,16 +194,23 @@ class LifetimeChecker {
}
void inferAnnotations() {
- // FIXME: To maximise inference propagation, functions should be analyzed in
- // post-order of the call graph, allowing inferred annotations to propagate
- // through the call chain
- // FIXME: Add the inferred attribute to all redeclarations of the function,
- // not just the definition being analyzed.
for (const auto &[ConstPVD, EscapeExpr] : AnnotationWarningsMap) {
ParmVarDecl *PVD = const_cast<ParmVarDecl *>(ConstPVD);
- if (!PVD->hasAttr<LifetimeBoundAttr>())
+ if (!PVD->hasAttr<LifetimeBoundAttr>()) {
PVD->addAttr(
LifetimeBoundAttr::CreateImplicit(AST, PVD->getLocation()));
+ if (const FunctionDecl *FD =
----------------
usx95 wrote:
The current convention is to use the mostRecentDecl to lookup the annotation. Sema takes care of merging the annotations from old decl to new decl so the latest decl is the most updated one.
I would be inclined to use that to be more consistent with the existing conventions.
https://github.com/llvm/llvm-project/pull/174178
More information about the cfe-commits
mailing list