[libcxx-commits] [PATCH] D127401: [WIP][libc++] Use checked iterators with std::span when the debug mode is enabled

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 9 06:00:43 PDT 2022


ldionne created this revision.
Herald added a subscriber: arphaman.
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 instead of __wrap_iter, which means
we wouldn't get out-of-range checking with std::span's iterators, which
is really useful. Unfortunately, the current implementation of the debug
mode implies that a bunch of non-trivial calls need to be inserted in
span's constructors and destructors, which is not ideal. In particular,
it means that we cannot keep std::span trivially copyable and destructible
when the debug mode is enabled.

As a fly-by change, this commit removes the _LIBCPP_ABI_SPAN_POINTER_ITERATORS
knob -- not using raw pointers in place of iterators is extremely useful
for users not to start depending on properties of iterators that are not
guaranteed, which allows them to e.g. enable the debug mode without fixing
their code.

As a follow-up change, I suggest reworking the underlying implementation
of the debug mode such that containers don't need to be registered in
order to get bounds-checking iterators.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127401

Files:
  libcxx/include/__config
  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/std/containers/views/views.span/span.cons/span.dtor.compile.pass.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
  libcxx/test/std/containers/views/views.span/trivially_copyable.compile.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127401.435519.patch
Type: text/x-patch
Size: 44583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220609/b1931820/attachment-0001.bin>


More information about the libcxx-commits mailing list