[llvm-branch-commits] [clang] [LifetimeSafety] Implicit lifetimebound for accessor methods of GSL owners only (PR #174741)

Utkarsh Saxena via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 8 02:13:29 PST 2026


https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/174741

>From 2f6fe84f3c108a898d5818245639abc77c93c25e Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena <usx at google.com>
Date: Tue, 16 Dec 2025 12:13:42 +0000
Subject: [PATCH] only-for-owners

---
 clang/lib/Analysis/LifetimeSafety/LifetimeAnnotations.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Analysis/LifetimeSafety/LifetimeAnnotations.cpp b/clang/lib/Analysis/LifetimeSafety/LifetimeAnnotations.cpp
index 2772fe20de19b..f6afc43843a82 100644
--- a/clang/lib/Analysis/LifetimeSafety/LifetimeAnnotations.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/LifetimeAnnotations.cpp
@@ -99,7 +99,8 @@ bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
   if (!isGslPointerType(Callee->getFunctionObjectParameterType()) &&
       !isGslOwnerType(Callee->getFunctionObjectParameterType()))
     return false;
-  if (isPointerLikeType(Callee->getReturnType())) {
+  if (isPointerLikeType(Callee->getReturnType()) &&
+      isGslOwnerType(Callee->getFunctionObjectParameterType())) {
     if (!Callee->getIdentifier())
       return false;
     return llvm::StringSwitch<bool>(Callee->getName())



More information about the llvm-branch-commits mailing list