================
@@ -174,13 +174,41 @@ bool shouldTrackImplicitObjectArg(const CXXMethodDecl 
*Callee,
 }
 
 bool shouldTrackFirstArgument(const FunctionDecl *FD) {
-  if (!FD->getIdentifier() || FD->getNumParams() != 1)
+  if (!FD->getIdentifier() || FD->getNumParams() < 1)
     return false;
+  if (!FD->isInStdNamespace())
+    return false;
+  // Track std:: algorithm functions that return an iterator whose lifetime is
+  // bound to the first argument.
+  if (FD->getNumParams() >= 2 && FD->isInStdNamespace() &&
+      isGslPointerType(FD->getReturnType())) {
+    if (llvm::StringSwitch<bool>(FD->getName())
+            .Cases(
+                {
+                    "find",
----------------
Xazax-hun wrote:

How comprehensive do we want to be here?

There are the `ranges` variants. 

And some more STL functions that modify the container like `rotate`, or 
`partition` also return iterators that are lifetime dependent.

That being said, I am also fine landing support for some of those in a 
follow-up. 

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

Reply via email to