================
@@ -1288,8 +1288,11 @@ checkExprLifetimeImpl(Sema &SemaRef, const
InitializedEntity *InitEntity,
// Suppress false positives for code like the one below:
// Ctor(unique_ptr<T> up) : pointer(up.get()), owner(move(up)) {}
// FIXME: move this logic to analyzePathForGSLPointer.
- if (DRE && isGslOwnerType(DRE->getType()))
- return false;
+ if (DRE && isGslOwnerType(DRE->getType())) {
+ auto *Member = ExtendingEntity ? ExtendingEntity->getDecl() :
nullptr;
+ if (!Member || !isGslPointerType(Member->getType()))
----------------
ChenMiaoi wrote:
``` cc
struct Safe {
std::span<int> view;
std::vector<int> owner;
Safe(std::vector<int> v)
: view(v), owner(std::move(v)) {}
};
```
`std::span<int>` is a GSL pointer type, so this change also affects the example
above. However, moving v into owner preserves pointers to its elements, so view
remains valid after the constructor returns. I tested this locally and found
that the patch introduces a false positive for this case.
https://github.com/llvm/llvm-project/pull/195981
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits