[clang] [LifetimeSafety] Prevent false-negative lifetimebound verification when origin escapes in an unrelated manner (PR #200786)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 1 05:24:02 PDT 2026
================
@@ -148,9 +148,10 @@ class LifetimeChecker {
// field!
};
auto CheckImplicitThis = [&](const CXXMethodDecl *MD) {
- if (implicitObjectParamIsLifetimeBound(MD))
- VerifiedLiftimeboundEscapes.insert(MD);
- else if (auto *ReturnEsc = dyn_cast<ReturnEscapeFact>(OEF))
+ if (implicitObjectParamIsLifetimeBound(MD)) {
+ if (isa<ReturnEscapeFact>(OEF))
+ VerifiedLiftimeboundEscapes.insert(MD);
+ } else if (auto *ReturnEsc = dyn_cast<ReturnEscapeFact>(OEF))
AnnotationWarningsMap.try_emplace(MD, ReturnEsc->getReturnExpr());
----------------
Xazax-hun wrote:
I think it might be possible to simplify this a bit.
```suggestion
if (auto *ReturnEsc = dyn_cast<ReturnEscapeFact>(OEF)) {
if (implicitObjectParamIsLifetimeBound(MD))
VerifiedLiftimeboundEscapes.insert(MD);
else
AnnotationWarningsMap.try_emplace(MD, ReturnEsc->getReturnExpr());
}
```
https://github.com/llvm/llvm-project/pull/200786
More information about the cfe-commits
mailing list