================
@@ -152,8 +152,19 @@ bool shouldTrackImplicitObjectArg(const CXXMethodDecl
*Callee,
return false;
if (isPointerLikeType(Callee->getReturnType())) {
- if (!Callee->getIdentifier())
+ if (!Callee->getIdentifier()) {
+ // e.g., std::optional<T>::operator->() returns T*.
+ if (Callee->getParent()->hasAttr<OwnerAttr>() &&
+ Callee->getOverloadedOperator() == OverloadedOperatorKind::OO_Arrow)
{
+ if (RunningUnderLifetimeSafety)
+ return true;
+ // For Sema analysis, don't track operator-> when the pointee is a GSL
+ // Pointer (e.g., optional<string_view>), as Sema can't distinguish the
+ // Pointer object's lifetime from the data it observes.
+ return !isGslPointerType(Callee->getReturnType()->getPointeeType());
----------------
aeft wrote:
That makes sense. Updated.
https://github.com/llvm/llvm-project/pull/184725
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits