[clang] [clang] Don't consider the lifetimeboundCall when analyzing the gsl pointer construction. (PR #114044)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 06:14:40 PDT 2024


================
@@ -1094,6 +1094,24 @@ static bool pathOnlyHandlesGslPointer(IndirectLocalPath &Path) {
   return false;
 }
 
+static bool
+isLifetimeboundInterleaveInGSL(llvm::ArrayRef<IndirectLocalPathEntry> PathRef) {
----------------
Xazax-hun wrote:

I am just wondering if this is the right approach to filter this problem out.

I think in the problematic code example `[[clang::lifetimebound]]` describes the lifetime of the returned reference, not the lifetime of the `gsl::pointer` annotated type. So, I think the mismatch is trying to apply the lifetimebound logic to the `gsl::pointer` in this particular example.

I think my point is, probably not all interleavings are bad, but here the `gsl::pointer` and the `lifetimebound` apply to different levels of indirection and I am wondering it that needs to be part of our filtering. 

https://github.com/llvm/llvm-project/pull/114044


More information about the cfe-commits mailing list