[clang] [LifetimeSafety] Track STL algorithm functions that return lifetimebound iterators (PR #179227)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 2 07:15:32 PST 2026
================
@@ -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",
----------------
usx95 wrote:
As much as we can I guess. I can add more in follow ups. Feel free to suggest more.
https://github.com/llvm/llvm-project/pull/179227
More information about the cfe-commits
mailing list