[clang] [LifetimeSafety] Add support for iterator arithmetic (PR #195442)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Sun May 3 11:24:23 PDT 2026


================
@@ -283,6 +283,25 @@ bool isUniquePtrRelease(const CXXMethodDecl &MD) {
          MD.getNumParams() == 0 && isStdUniquePtr(*MD.getParent());
 }
 
+bool isIteratorType(const CXXRecordDecl *RD) {
+  // FIXME: Extend this to cover more iterator wrapper types used by standard
+  // library implementations.
+  static const llvm::StringSet<> Iterators = {
+      // Standard reverse iterator wrapper.
+      "reverse_iterator",
+      // libstdc++ contiguous iterator wrapper.
+      "__normal_iterator",
+      // libc++ contiguous iterator wrapper.
+      "__wrap_iter"};
+  return RD && isInStlNamespace(RD) && Iterators.contains(getName(*RD));
+}
+
+bool isPropagatingIteratorOp(OverloadedOperatorKind OP) {
----------------
usx95 wrote:

I think it would be clearer if we can inline this at the usage.

https://github.com/llvm/llvm-project/pull/195442


More information about the cfe-commits mailing list