[llvm-branch-commits] [clang] [analyzer] Only bind aggregate lifetime sources in LifetimeModeling for annotated functions (PR #214824)
Benedek Kaibas via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 10 02:29:07 PDT 2026
================
@@ -181,19 +190,26 @@ void LifetimeModeling::checkPostCall(const CallEvent &Call,
return;
SVal RetVal = Call.getReturnValue();
- SmallVector<const MemRegion *, 4> AggrRegs =
- lifetime_modeling::getRegionsFromAggrVal(RetVal, C);
- for (const MemRegion *I : AggrRegs) {
- State = bindSource(State, RetVal, I);
+ if (hasAnyParamLifetimeAnnotated(FD)) {
+ auto AggrRegs = lifetime_modeling::getRegionsFromAggrVal(RetVal, C);
+ for (const MemRegion *R : AggrRegs) {
+ State = bindSource(State, RetVal, R);
+ }
}
for (const ParmVarDecl *PVD : FD->parameters()) {
if (PVD->hasAttr<LifetimeBoundAttr>()) {
unsigned Idx = PVD->getFunctionScopeIndex();
SVal Arg = Call.getArgSVal(Idx);
- if (const MemRegion *ArgValRegion = Arg.getAsRegion())
+ if (const MemRegion *ArgValRegion = Arg.getAsRegion()) {
State = bindSource(State, RetVal, ArgValRegion);
+ } else {
+ auto AggrRegs = lifetime_modeling::getRegionsFromAggrVal(Arg, C);
----------------
benedekaibas wrote:
I have done the changes for it here: [354bafa](https://github.com/llvm/llvm-project/pull/214824/commits/354bafac513c6e335cbc8bceab783699972e052f)
I also tried to implement this logic in `getRegionsFromAggrVal` directly without creating a new helper, but the test suite failed, so I just moved the logic of its own helper and named it `getRegionsFromSVal`.
https://github.com/llvm/llvm-project/pull/214824
More information about the llvm-branch-commits
mailing list