[libc++] Use bounded iterators in std::span when the debug mode is enabled
Previously, we'd use raw pointers when the debug mode was enabled,
which means we wouldn't get out-of-range checking with std::span's
iterators.
This patch introduces a new class called __bounded_iter which can
be used to wrap iterators and make them carry around bounds-related
information. This allows iterators to assert when they are dereferenced
outside of their bounds.
As a fly-by change, this commit removes the _LIBCPP_ABI_SPAN_POINTER_ITERATORS
knob. Indeed, not using a raw pointer as the iterator type is useful to
avoid users depending on properties of raw pointers in their code.
This is an alternative to D127401.
Differential Revision: https://reviews.llvm.org/D127418
NOKEYCHECK=True
GitOrigin-RevId: 633d1d0df766d5838c4c0b675fc7ac077159cec6
diff --git a/include/module.modulemap.in b/include/module.modulemap.in
index cd71a3c..173f789 100644
--- a/include/module.modulemap.in
+++ b/include/module.modulemap.in
@@ -701,6 +701,7 @@
module access { private header "__iterator/access.h" }
module advance { private header "__iterator/advance.h" }
module back_insert_iterator { private header "__iterator/back_insert_iterator.h" }
+ module bounded_iter { private header "__iterator/bounded_iter.h" }
module common_iterator { private header "__iterator/common_iterator.h" }
module concepts { private header "__iterator/concepts.h" }
module counted_iterator { private header "__iterator/counted_iterator.h" }