[llvm-branch-commits] [clang] [analyzer] Only bind aggregate lifetime sources in LifetimeModeling for annotated functions (PR #214824)
Balázs Benics via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Aug 9 15:46:08 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);
----------------
steakhal wrote:
Looking at the usage of this, wouldnt it make sense to have an abstraction that takes an abitrary sval and returns a list of regions? For locations it returns that as a single list. For aggregates, does what it does here.
https://github.com/llvm/llvm-project/pull/214824
More information about the llvm-branch-commits
mailing list