[libcxx-commits] [libcxx] f1417eb - [libcxx][module-map] creates submodules for private headers

Christopher Di Bella via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 3 11:19:35 PDT 2021


Author: Christopher Di Bella
Date: 2021-06-03T18:18:30Z
New Revision: f1417eb9b1f51b689c78dd8cb0114c1749dd2845

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

LOG: [libcxx][module-map] creates submodules for private headers

Most of our private headers need to be treated as submodules so that
Clang modules can export things correctly. Previous commits that split
monolithic headers into smaller chunks were unaware of this requirement,
and so this is being addressed in one fell swoop. Moving forward, most
new headers will need to have their own submodule (anything that's
conditionally included is exempt from this rule, which means `__support`
headers aren't made into submodules).

This hasn't been marked NFC, since I'm not 100% sure that's the case.

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

Added: 
    

Modified: 
    libcxx/include/__iterator/advance.h
    libcxx/include/__iterator/indirect_concepts.h
    libcxx/include/__iterator/next.h
    libcxx/include/__iterator/prev.h
    libcxx/include/__memory/allocation_guard.h
    libcxx/include/__memory/allocator.h
    libcxx/include/__memory/allocator_traits.h
    libcxx/include/__memory/pointer_safety.h
    libcxx/include/__memory/pointer_traits.h
    libcxx/include/module.modulemap

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__iterator/advance.h b/libcxx/include/__iterator/advance.h
index f482d18d602ea..0b89fd4bff14d 100644
--- a/libcxx/include/__iterator/advance.h
+++ b/libcxx/include/__iterator/advance.h
@@ -15,6 +15,7 @@
 #include <__function_like.h>
 #include <__iterator/concepts.h>
 #include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
 #include <concepts>
 #include <limits>
 #include <type_traits>

diff  --git a/libcxx/include/__iterator/indirect_concepts.h b/libcxx/include/__iterator/indirect_concepts.h
index d0ec08c143065..fcc418e656af8 100644
--- a/libcxx/include/__iterator/indirect_concepts.h
+++ b/libcxx/include/__iterator/indirect_concepts.h
@@ -12,6 +12,8 @@
 #include <__config>
 #include <__iterator/concepts.h>
 #include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/readable_traits.h>
 #include <concepts>
 #include <type_traits>
 

diff  --git a/libcxx/include/__iterator/next.h b/libcxx/include/__iterator/next.h
index 57cd5bab09f30..ab0843cc19162 100644
--- a/libcxx/include/__iterator/next.h
+++ b/libcxx/include/__iterator/next.h
@@ -15,6 +15,8 @@
 #include <__iterator/advance.h>
 #include <__iterator/concepts.h>
 #include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

diff  --git a/libcxx/include/__iterator/prev.h b/libcxx/include/__iterator/prev.h
index 3a32f368cb078..0601ee01b9658 100644
--- a/libcxx/include/__iterator/prev.h
+++ b/libcxx/include/__iterator/prev.h
@@ -15,6 +15,8 @@
 #include <__iterator/advance.h>
 #include <__iterator/concepts.h>
 #include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

diff  --git a/libcxx/include/__memory/allocation_guard.h b/libcxx/include/__memory/allocation_guard.h
index 9d8d2d6e1a8f3..4987af293d14c 100644
--- a/libcxx/include/__memory/allocation_guard.h
+++ b/libcxx/include/__memory/allocation_guard.h
@@ -13,6 +13,7 @@
 #include <__config>
 #include <__memory/allocator_traits.h>
 #include <cstddef>
+#include <utility>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

diff  --git a/libcxx/include/__memory/allocator.h b/libcxx/include/__memory/allocator.h
index ddd411c41ad42..7e022248672dc 100644
--- a/libcxx/include/__memory/allocator.h
+++ b/libcxx/include/__memory/allocator.h
@@ -220,6 +220,9 @@ template <class _Tp, class _Up>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
 
+template <class _Tp>
+struct __is_default_allocator<allocator<_Tp> > : true_type { };
+
 _LIBCPP_END_NAMESPACE_STD
 
 _LIBCPP_POP_MACROS

diff  --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h
index a5d151043b4a8..89afaee80e8ed 100644
--- a/libcxx/include/__memory/allocator_traits.h
+++ b/libcxx/include/__memory/allocator_traits.h
@@ -361,9 +361,6 @@ struct __rebind_alloc_helper {
 template <class _Tp>
 struct __is_default_allocator : false_type { };
 
-template <class _Tp>
-struct __is_default_allocator<allocator<_Tp> > : true_type { };
-
 // __is_cpp17_move_insertable
 template <class _Alloc, class = void>
 struct __is_cpp17_move_insertable

diff  --git a/libcxx/include/__memory/pointer_safety.h b/libcxx/include/__memory/pointer_safety.h
index bdfed3fa3a307..87a6a9659e0c1 100644
--- a/libcxx/include/__memory/pointer_safety.h
+++ b/libcxx/include/__memory/pointer_safety.h
@@ -11,6 +11,7 @@
 #define _LIBCPP___MEMORY_POINTER_SAFETY_H
 
 #include <__config>
+#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

diff  --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
index 6730066edc31c..d5442b84e2aae 100644
--- a/libcxx/include/__memory/pointer_traits.h
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -11,6 +11,7 @@
 #define _LIBCPP___MEMORY_POINTER_TRAITS_H
 
 #include <__config>
+#include <__memory/addressof.h>
 #include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

diff  --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index a6f10a02368a3..a52c014fe2f3d 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -260,6 +260,7 @@ module std [system] {
     export *
   }
   module compare {
+    requires cplusplus20
     header "compare"
     export *
   }
@@ -268,6 +269,7 @@ module std [system] {
     export *
   }
   module concepts {
+    requires cplusplus20
     header "concepts"
     export *
   }
@@ -293,8 +295,14 @@ module std [system] {
     export *
   }
   module format {
+    requires cplusplus20
     header "format"
     export *
+
+    module __format {
+      module format_error         { header "__format/format_error.h"         }
+      module format_parse_context { header "__format/format_parse_context.h" }
+    }
   }
   module forward_list {
     header "forward_list"
@@ -346,6 +354,20 @@ module std [system] {
   module iterator {
     header "iterator"
     export *
+
+    module __iterator {
+      module advance              { header "__iterator/advance.h"              }
+      module concepts             { header "__iterator/concepts.h"             }
+      module default_sentinel     { header "__iterator/default_sentinel.h"     }
+      module incrementable_traits { header "__iterator/incrementable_traits.h" }
+      module indirect_concepts    { header "__iterator/indirect_concepts.h"    }
+      module iter_move            { header "__iterator/iter_move.h"            }
+      module iterator_traits      { header "__iterator/iterator_traits.h"      }
+      module next                 { header "__iterator/next.h"                 }
+      module prev                 { header "__iterator/prev.h"                 }
+      module projected            { header "__iterator/projected.h"            }
+      module readable_traits      { header "__iterator/readable_traits.h"      }
+    }
   }
   module latch {
     requires cplusplus14
@@ -373,6 +395,23 @@ module std [system] {
   module memory {
     header "memory"
     export *
+
+    module __memory {
+      module addressof                { header "__memory/addressof.h"                }
+      module allocation_guard         { header "__memory/allocation_guard.h"         }
+      module allocator_traits         { header "__memory/allocator_traits.h"         }
+      module allocator                { header "__memory/allocator.h"                }
+      module auto_ptr                 { header "__memory/auto_ptr.h"                 }
+      module compressed_pair          { header "__memory/compressed_pair.h"          }
+      module construct_at             { header "__memory/construct_at.h"             }
+      module pointer_safety           { header "__memory/pointer_safety.h"           }
+      module pointer_traits           { header "__memory/pointer_traits.h"           }
+      module raw_storage_iterator     { header "__memory/raw_storage_iterator.h"     }
+      module shared_ptr               { header "__memory/shared_ptr.h"               }
+      module temporary_buffer         { header "__memory/temporary_buffer.h"         }
+      module uninitialized_algorithms { header "__memory/uninitialized_algorithms.h" }
+      module unique_ptr               { header "__memory/unique_ptr.h"               }
+    }
   }
   module mutex {
     header "mutex"
@@ -410,11 +449,23 @@ module std [system] {
     export *
   }
   module ranges {
+    requires cplusplus20
     header "ranges"
     export compare
     export initializer_list
     export iterator
     export *
+
+    module __ranges {
+      module access                 { header "__ranges/access.h"                 }
+      module concepts               { header "__ranges/concepts.h"               }
+      module data                   { header "__ranges/data.h"                   }
+      module empty                  { header "__ranges/empty.h"                  }
+      module enabled_borrowed_range { header "__ranges/enabled_borrowed_range.h" }
+      module size                   { header "__ranges/size.h"                   }
+      module view_interface         { header "__ranges/view_interface.h"         }
+      module view                   { header "__ranges/view.h"                   }
+    }
   }
   module ratio {
     header "ratio"
@@ -512,6 +563,12 @@ module std [system] {
     header "utility"
     export initializer_list
     export *
+
+    module __utility {
+      module to_underlying {
+        header "__utility/to_underlying.h"
+      }
+    }
   }
   module valarray {
     header "valarray"
@@ -533,22 +590,28 @@ module std [system] {
   }
 
   // FIXME: These should be private.
-  module __bit_reference { header "__bit_reference" export * }
-  module __bits { header "__bits" export * }
-  module __debug { header "__debug" export * }
-  module __errc { header "__errc" export * }
-  module __functional_base { header "__functional_base" export * }
-  module __hash_table { header "__hash_table" export * }
-  module __locale { header "__locale" export * }
-  module __mutex_base { header "__mutex_base" export * }
-  module __node_handle { header "__node_handle" export * }
-  module __split_buffer { header "__split_buffer" export * }
-  module __std_stream { header "__std_stream" export * }
-  module __string { header "__string" export * }
-  module __threading_support { header "__threading_support" export * }
-  module __tree { header "__tree" export * }
-  module __tuple { header "__tuple" export * }
-  module __undef_macros { header "__undef_macros" export * }
+  module __availability       { header "__availability"       export * }
+  module __bit_reference      { header "__bit_reference"      export * }
+  module __bits               { header "__bits"               export * }
+  module __config             { header "__config"             export * }
+  module __debug              { header "__debug"              export * }
+  module __errc               { header "__errc"               export * }
+  module __function_like      { header "__function_like.h"    export * }
+  module __functional_base    { header "__functional_base" export * }
+  // TODO: modularise __functional_(base_)?03
+  module __hash_table         { header "__hash_table"         export * }
+  // libcpp_version not modularised since it's just a version number
+  module __locale             { header "__locale"             export * }
+  module __mutex_base         { header "__mutex_base"         export * }
+  module __node_handle        { header "__node_handle"        export * }
+  module __nullptr            { header "__nullptr"            export * }
+  module __split_buffer       { header "__split_buffer"       export * }
+  module __std_stream         { header "__std_stream"         export * }
+  module __string             { header "__string"             export * }
+  module __threading_support  { header "__threading_support"  export * }
+  module __tree               { header "__tree"               export * }
+  module __tuple              { header "__tuple"              export * }
+  module __undef_macros       { header "__undef_macros"       export * }
 
   module experimental {
     requires cplusplus11


        


More information about the libcxx-commits mailing list