[libcxx-commits] [PATCH] D127418: [libc++] Use bounded iterators in std::span when the debug mode is enabled
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 9 11:04:59 PDT 2022
ldionne created this revision.
Herald added subscribers: arphaman, mgorny.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
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 <https://reviews.llvm.org/D127401>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127418
Files:
libcxx/include/CMakeLists.txt
libcxx/include/__config
libcxx/include/__iterator/bounded_iter.h
libcxx/include/iterator
libcxx/include/span
libcxx/test/libcxx/containers/views/views.span/debug.iterator-indexing.pass.cpp
libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp
libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp
libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp
libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp
libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp
libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
libcxx/test/libcxx/private_headers.verify.cpp
libcxx/test/std/containers/views/views.span/span.sub/first.fail.cpp
libcxx/test/std/containers/views/views.span/span.sub/first.verify.cpp
libcxx/test/std/containers/views/views.span/span.sub/last.fail.cpp
libcxx/test/std/containers/views/views.span/span.sub/last.verify.cpp
libcxx/test/std/containers/views/views.span/span.sub/subspan.fail.cpp
libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127418.435617.patch
Type: text/x-patch
Size: 42872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220609/d58f7e1c/attachment-0001.bin>
More information about the libcxx-commits
mailing list