[all-commits] [llvm/llvm-project] 633d1d: [libc++] Use bounded iterators in std::span when t...
Louis Dionne via All-commits
all-commits at lists.llvm.org
Mon Jun 27 05:35:12 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 633d1d0df766d5838c4c0b675fc7ac077159cec6
https://github.com/llvm/llvm-project/commit/633d1d0df766d5838c4c0b675fc7ac077159cec6
Author: Louis Dionne <ldionne.2 at gmail.com>
Date: 2022-06-27 (Mon, 27 Jun 2022)
Changed paths:
M libcxx/include/CMakeLists.txt
M libcxx/include/__config
A libcxx/include/__iterator/bounded_iter.h
M libcxx/include/iterator
M libcxx/include/module.modulemap.in
M libcxx/include/span
A libcxx/test/libcxx/containers/views/views.span/debug.iterator-indexing.pass.cpp
A libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp
A libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp
A libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp
A libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp
A libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp
A libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
A libcxx/test/libcxx/iterators/bounded_iter/arithmetic.pass.cpp
A libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp
A libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
A libcxx/test/libcxx/iterators/bounded_iter/pointer_traits.pass.cpp
A libcxx/test/libcxx/iterators/bounded_iter/types.compile.pass.cpp
M libcxx/test/libcxx/private_headers.verify.cpp
R libcxx/test/std/containers/views/views.span/span.sub/first.fail.cpp
A libcxx/test/std/containers/views/views.span/span.sub/first.verify.cpp
R libcxx/test/std/containers/views/views.span/span.sub/last.fail.cpp
A libcxx/test/std/containers/views/views.span/span.sub/last.verify.cpp
R libcxx/test/std/containers/views/views.span/span.sub/subspan.fail.cpp
A libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
Log Message:
-----------
[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
More information about the All-commits
mailing list