[libcxx-commits] [libcxx] 0cf6538 - [libcxx][modularisation] properly modularises advance, next, and prev

Christopher Di Bella via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 22 16:30:16 PDT 2021


Author: Christopher Di Bella
Date: 2021-07-22T23:30:02Z
New Revision: 0cf65382ade209d11c186639c18a2e262866d689

URL: https://github.com/llvm/llvm-project/commit/0cf65382ade209d11c186639c18a2e262866d689
DIFF: https://github.com/llvm/llvm-project/commit/0cf65382ade209d11c186639c18a2e262866d689.diff

LOG: [libcxx][modularisation] properly modularises advance, next, and prev

`__function_like` wasn't being exported, so certain properties of the
`ranges` functions weren't being propagated in modules land.

Differential Revision: https://reviews.llvm.org/D105078

Added: 
    

Modified: 
    libcxx/include/__iterator/advance.h
    libcxx/include/module.modulemap
    libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/special_function.compile.pass.cpp
    libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.next/special_function.compile.pass.cpp
    libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.prev/special_function.compile.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__iterator/advance.h b/libcxx/include/__iterator/advance.h
index 6f7c33e4c1a62..48180b27f5875 100644
--- a/libcxx/include/__iterator/advance.h
+++ b/libcxx/include/__iterator/advance.h
@@ -16,11 +16,11 @@
 #include <__iterator/concepts.h>
 #include <__iterator/incrementable_traits.h>
 #include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
 #include <cstdlib>
 #include <concepts>
 #include <limits>
 #include <type_traits>
-#include <utility>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -70,7 +70,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 void advance(_Inp
 
 namespace ranges {
 // [range.iter.op.advance]
-struct __advance_fn final : __function_like {
+struct __advance_fn final : private __function_like {
 private:
   template <class _Tp>
   _LIBCPP_HIDE_FROM_ABI
@@ -129,7 +129,7 @@ struct __advance_fn final : __function_like {
   constexpr void operator()(_Ip& __i, _Sp __bound) const {
     // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`.
     if constexpr (assignable_from<_Ip&, _Sp>) {
-      __i = std::move(__bound);
+      __i = _VSTD::move(__bound);
     }
     // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`.
     else if constexpr (sized_sentinel_for<_Sp, _Ip>) {

diff  --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 4d2101ecf5daf..982002ee4e11a 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -478,7 +478,10 @@ module std [system] {
 
     module __iterator {
       module access                { private header "__iterator/access.h" }
-      module advance               { private header "__iterator/advance.h" }
+      module advance               {
+        private header "__iterator/advance.h"
+        export __function_like
+      }
       module back_insert_iterator  { private header "__iterator/back_insert_iterator.h" }
       module common_iterator       { private header "__iterator/common_iterator.h" }
       module concepts              { private header "__iterator/concepts.h" }
@@ -497,10 +500,16 @@ module std [system] {
       module iterator              { private header "__iterator/iterator.h" }
       module iterator_traits       { private header "__iterator/iterator_traits.h" }
       module move_iterator         { private header "__iterator/move_iterator.h" }
-      module next                  { private header "__iterator/next.h" }
+      module next                  {
+        private header "__iterator/next.h"
+        export __function_like
+      }
       module ostream_iterator      { private header "__iterator/ostream_iterator.h" }
       module ostreambuf_iterator   { private header "__iterator/ostreambuf_iterator.h" }
-      module prev                  { private header "__iterator/prev.h" }
+      module prev                  {
+        private header "__iterator/prev.h"
+        export __function_like
+      }
       module projected             { private header "__iterator/projected.h" }
       module readable_traits       { private header "__iterator/readable_traits.h" }
       module reverse_access        { private header "__iterator/reverse_access.h" }

diff  --git a/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/special_function.compile.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/special_function.compile.pass.cpp
index 281486c33bdb3..1c34010ac09bc 100644
--- a/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/special_function.compile.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/special_function.compile.pass.cpp
@@ -10,12 +10,6 @@
 // UNSUPPORTED: libcpp-no-concepts
 // UNSUPPORTED: gcc-10
 
-// Clang has a bug when modules are enabled that causes `__function_like::operator&`
-// not to be picked up by the derived class.
-// XFAIL: clang-11 && modules-build
-// XFAIL: clang-12 && modules-build
-// XFAIL: clang-13 && modules-build
-
 // ranges::advance
 
 #include <iterator>

diff  --git a/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.next/special_function.compile.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.next/special_function.compile.pass.cpp
index 4de702f4c62fc..2f873da6bc422 100644
--- a/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.next/special_function.compile.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.next/special_function.compile.pass.cpp
@@ -10,12 +10,6 @@
 // UNSUPPORTED: libcpp-no-concepts
 // UNSUPPORTED: gcc-10
 
-// Clang has a bug when modules are enabled that causes `__function_like::operator&`
-// not to be picked up by the derived class.
-// XFAIL: clang-11 && modules-build
-// XFAIL: clang-12 && modules-build
-// XFAIL: clang-13 && modules-build
-
 // ranges::next
 
 #include <iterator>

diff  --git a/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.prev/special_function.compile.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.prev/special_function.compile.pass.cpp
index 4e949a6d49db5..773f98e5c9928 100644
--- a/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.prev/special_function.compile.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.prev/special_function.compile.pass.cpp
@@ -10,12 +10,6 @@
 // UNSUPPORTED: libcpp-no-concepts
 // UNSUPPORTED: gcc-10
 
-// Clang has a bug when modules are enabled that causes `__function_like::operator&`
-// not to be picked up by the derived class.
-// XFAIL: clang-11 && modules-build
-// XFAIL: clang-12 && modules-build
-// XFAIL: clang-13 && modules-build
-
 // ranges::prev
 
 #include <iterator>


        


More information about the libcxx-commits mailing list