[libcxx-commits] [libcxx] 05d164b - Revert "[libc++] NFC: Move unwrap_iter to its own header"
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 2 12:59:33 PDT 2021
Author: Louis Dionne
Date: 2021-06-02T15:58:27-04:00
New Revision: 05d164b25c403c0ab9a114f25e750c6410d4d86c
URL: https://github.com/llvm/llvm-project/commit/05d164b25c403c0ab9a114f25e750c6410d4d86c
DIFF: https://github.com/llvm/llvm-project/commit/05d164b25c403c0ab9a114f25e750c6410d4d86c.diff
LOG: Revert "[libc++] NFC: Move unwrap_iter to its own header"
This reverts commit 924ea3bb53 *again*, this time because it broke the
LLDB build with modules. We need to figure out what's up with the libc++
modules build once and for all.
Differential Revision: https://reviews.llvm.org/D103369
Added:
Modified:
libcxx/include/CMakeLists.txt
libcxx/include/algorithm
libcxx/include/module.modulemap
Removed:
libcxx/include/__algorithm/unwrap_iter.h
################################################################################
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 90110512c0cf..b0c7b47958f3 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -1,5 +1,4 @@
set(files
- __algorithm/unwrap_iter.h
__availability
__bit_reference
__bits
diff --git a/libcxx/include/__algorithm/unwrap_iter.h b/libcxx/include/__algorithm/unwrap_iter.h
deleted file mode 100644
index 70dc22e7be83..000000000000
--- a/libcxx/include/__algorithm/unwrap_iter.h
+++ /dev/null
@@ -1,89 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___ALGORITHM_UNWRAP_ITER_H
-#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H
-
-#include <__config>
-#include <__iterator/iterator_traits.h> // __is_cpp17_contiguous_iterator
-#include <__memory/pointer_traits.h> // __to_address
-#include <utility>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-// __unwrap_iter, __rewrap_iter
-
-// The job of __unwrap_iter is to lower contiguous iterators (such as
-// vector<T>::iterator) into pointers, to reduce the number of template
-// instantiations and to enable pointer-based optimizations e.g. in std::copy.
-// For iterators that are not contiguous, it must be a no-op.
-// In debug mode, we don't do this.
-//
-// __unwrap_iter is non-constexpr for user-defined iterators whose
-// `to_address` and/or `operator->` is non-constexpr. This is okay; but we
-// try to avoid doing __unwrap_iter in constant-evaluated contexts anyway.
-//
-// Some algorithms (e.g. std::copy, but not std::sort) need to convert an
-// "unwrapped" result back into a contiguous iterator. Since contiguous iterators
-// are random-access, we can do this portably using iterator arithmetic; this
-// is the job of __rewrap_iter.
-
-template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value>
-struct __unwrap_iter_impl {
- static _LIBCPP_CONSTEXPR _Iter
- __apply(_Iter __i) _NOEXCEPT {
- return __i;
- }
-};
-
-#if _LIBCPP_DEBUG_LEVEL < 2
-
-template <class _Iter>
-struct __unwrap_iter_impl<_Iter, true> {
- static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>()))
- __apply(_Iter __i) _NOEXCEPT {
- return _VSTD::__to_address(__i);
- }
-};
-
-#endif // _LIBCPP_DEBUG_LEVEL < 2
-
-template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-decltype(_Impl::__apply(_VSTD::declval<_Iter>()))
-__unwrap_iter(_Iter __i) _NOEXCEPT
-{
- return _Impl::__apply(__i);
-}
-
-template<class _OrigIter>
-_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
-{
- return __result;
-}
-
-template<class _OrigIter, class _UnwrappedIter>
-_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)
-{
- // Precondition: __result is reachable from __first
- // Precondition: _OrigIter is a contiguous iterator
- return __first + (__result - _VSTD::__unwrap_iter(__first));
-}
-
-_LIBCPP_END_NAMESPACE_STD
-
-_LIBCPP_POP_MACROS
-
-#endif // _LIBCPP___ALGORITHM_UNWRAP_ITER_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 5d8fc8292630..1ae84f7dff7f 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -645,7 +645,6 @@ template <class BidirectionalIterator, class Compare>
*/
-#include <__algorithm/unwrap_iter.h>
#include <__config>
#include <__bits> // __libcpp_clz
#include <cstddef>
@@ -1640,6 +1639,65 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const
__value_, __equal_to<__v, _Tp>());
}
+// __unwrap_iter, __rewrap_iter
+
+// The job of __unwrap_iter is to lower contiguous iterators (such as
+// vector<T>::iterator) into pointers, to reduce the number of template
+// instantiations and to enable pointer-based optimizations e.g. in std::copy.
+// For iterators that are not contiguous, it must be a no-op.
+// In debug mode, we don't do this.
+//
+// __unwrap_iter is non-constexpr for user-defined iterators whose
+// `to_address` and/or `operator->` is non-constexpr. This is okay; but we
+// try to avoid doing __unwrap_iter in constant-evaluated contexts anyway.
+//
+// Some algorithms (e.g. std::copy, but not std::sort) need to convert an
+// "unwrapped" result back into a contiguous iterator. Since contiguous iterators
+// are random-access, we can do this portably using iterator arithmetic; this
+// is the job of __rewrap_iter.
+
+template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value>
+struct __unwrap_iter_impl {
+ static _LIBCPP_CONSTEXPR _Iter
+ __apply(_Iter __i) _NOEXCEPT {
+ return __i;
+ }
+};
+
+#if _LIBCPP_DEBUG_LEVEL < 2
+
+template <class _Iter>
+struct __unwrap_iter_impl<_Iter, true> {
+ static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>()))
+ __apply(_Iter __i) _NOEXCEPT {
+ return _VSTD::__to_address(__i);
+ }
+};
+
+#endif // _LIBCPP_DEBUG_LEVEL < 2
+
+template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+decltype(_Impl::__apply(declval<_Iter>()))
+__unwrap_iter(_Iter __i) _NOEXCEPT
+{
+ return _Impl::__apply(__i);
+}
+
+template<class _OrigIter>
+_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
+{
+ return __result;
+}
+
+template<class _OrigIter, class _UnwrappedIter>
+_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)
+{
+ // Precondition: __result is reachable from __first
+ // Precondition: _OrigIter is a contiguous iterator
+ return __first + (__result - _VSTD::__unwrap_iter(__first));
+}
+
// copy
template <class _InputIterator, class _OutputIterator>
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 140ff506c92e..a6f10a02368a 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -539,7 +539,6 @@ module std [system] {
module __errc { header "__errc" export * }
module __functional_base { header "__functional_base" export * }
module __hash_table { header "__hash_table" export * }
- module __iterator_iterator_traits { header "__iterator/iterator_traits.h" export * }
module __locale { header "__locale" export * }
module __mutex_base { header "__mutex_base" export * }
module __node_handle { header "__node_handle" export * }
More information about the libcxx-commits
mailing list