[clang] [clang] Diagnose dangling issues for the "Container<GSLPointer>" case. (PR #107213)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 9 03:22:18 PDT 2024
================
@@ -990,13 +1009,16 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
// int &p = *localUniquePtr;
// someContainer.add(std::move(localUniquePtr));
// return p;
- IsLocalGslOwner = isRecordWithAttr<OwnerAttr>(L->getType());
+ IsLocalGslOwner =
+ isRecordWithAttr<OwnerAttr>(L->getType()) &&
+ !isContainerOfPointer(L->getType()->getAsRecordDecl());
----------------
usx95 wrote:
This looks useful to be a extracted to a separate function, `IsGSLOwner`. This could be used to replace the use below as well.
There are other instances `!isRecordWithAttr<OwnerAttr>` which can be replaced as a no-op as well. It would make it more consistent and easy to follow.
https://github.com/llvm/llvm-project/pull/107213
More information about the cfe-commits
mailing list