================
@@ -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());
----------------
usx95 wrote:

Yes. I would prefer to have `-Wdangling`entirely unchanged. Please remove any 
added tests which fails for it. No need for FIXME. We already have several 
cases where lifetime-safety warns and dangling does not. 

The idea is that we plan to sunset `-Wdangling` at some point of time and 
replace with lifetime safety

https://github.com/llvm/llvm-project/pull/184725
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to