[libcxx-commits] [libcxx] [libc++] Properly guard flat_map includes based on C++ version (PR #119227)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 9 08:44:29 PST 2024


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/119227

>From f0651c49c22840ec243ad8a71087b17d9ea3a350 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 9 Dec 2024 10:45:11 -0500
Subject: [PATCH 1/2] [libc++] Properly guard flat_map includes based on C++
 version

That's what we (try to) do consistently for all other umbrella headers.
---
 libcxx/include/flat_map                       |  9 ++++++--
 .../test/libcxx/transitive_includes/cxx03.csv | 22 -------------------
 .../test/libcxx/transitive_includes/cxx11.csv | 22 -------------------
 .../test/libcxx/transitive_includes/cxx14.csv | 22 -------------------
 .../test/libcxx/transitive_includes/cxx17.csv | 22 -------------------
 .../test/libcxx/transitive_includes/cxx20.csv | 22 -------------------
 6 files changed, 7 insertions(+), 112 deletions(-)

diff --git a/libcxx/include/flat_map b/libcxx/include/flat_map
index 15d79dd1ddca34..870dd2e26a2379 100644
--- a/libcxx/include/flat_map
+++ b/libcxx/include/flat_map
@@ -39,8 +39,13 @@ namespace std {
 
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
-#include <__flat_map/flat_map.h>
-#include <__flat_map/sorted_unique.h>
+
+#if _LIBCPP_STD_VER >= 23
+#  include <__flat_map/flat_map.h>
+#  include <__flat_map/sorted_unique.h>
+#endif
+
+// for feature-test macros
 #include <version>
 
 // standard required includes
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 72fccfd3649325..801f6cbf9060f8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -674,35 +674,13 @@ filesystem typeinfo
 filesystem utility
 filesystem variant
 filesystem version
-flat_map atomic
-flat_map cctype
-flat_map climits
 flat_map cmath
 flat_map compare
-flat_map concepts
 flat_map cstddef
 flat_map cstdint
-flat_map cstdio
-flat_map cstdlib
-flat_map cstring
-flat_map ctime
-flat_map cwchar
-flat_map cwctype
-flat_map exception
 flat_map initializer_list
-flat_map iosfwd
-flat_map iterator
 flat_map limits
-flat_map memory
-flat_map new
-flat_map optional
-flat_map ratio
-flat_map stdexcept
-flat_map tuple
 flat_map type_traits
-flat_map typeinfo
-flat_map utility
-flat_map variant
 flat_map version
 format algorithm
 format array
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 72fccfd3649325..801f6cbf9060f8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -674,35 +674,13 @@ filesystem typeinfo
 filesystem utility
 filesystem variant
 filesystem version
-flat_map atomic
-flat_map cctype
-flat_map climits
 flat_map cmath
 flat_map compare
-flat_map concepts
 flat_map cstddef
 flat_map cstdint
-flat_map cstdio
-flat_map cstdlib
-flat_map cstring
-flat_map ctime
-flat_map cwchar
-flat_map cwctype
-flat_map exception
 flat_map initializer_list
-flat_map iosfwd
-flat_map iterator
 flat_map limits
-flat_map memory
-flat_map new
-flat_map optional
-flat_map ratio
-flat_map stdexcept
-flat_map tuple
 flat_map type_traits
-flat_map typeinfo
-flat_map utility
-flat_map variant
 flat_map version
 format algorithm
 format array
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index fd36dace19c76c..9146a7079ee1e9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -692,35 +692,13 @@ filesystem typeinfo
 filesystem utility
 filesystem variant
 filesystem version
-flat_map atomic
-flat_map cctype
-flat_map climits
 flat_map cmath
 flat_map compare
-flat_map concepts
 flat_map cstddef
 flat_map cstdint
-flat_map cstdio
-flat_map cstdlib
-flat_map cstring
-flat_map ctime
-flat_map cwchar
-flat_map cwctype
-flat_map exception
 flat_map initializer_list
-flat_map iosfwd
-flat_map iterator
 flat_map limits
-flat_map memory
-flat_map new
-flat_map optional
-flat_map ratio
-flat_map stdexcept
-flat_map tuple
 flat_map type_traits
-flat_map typeinfo
-flat_map utility
-flat_map variant
 flat_map version
 format algorithm
 format array
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index eaec25f81e5821..a3518f7f62ecb9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -701,35 +701,13 @@ filesystem utility
 filesystem variant
 filesystem vector
 filesystem version
-flat_map atomic
-flat_map cctype
-flat_map climits
 flat_map cmath
 flat_map compare
-flat_map concepts
 flat_map cstddef
 flat_map cstdint
-flat_map cstdio
-flat_map cstdlib
-flat_map cstring
-flat_map ctime
-flat_map cwchar
-flat_map cwctype
-flat_map exception
 flat_map initializer_list
-flat_map iosfwd
-flat_map iterator
 flat_map limits
-flat_map memory
-flat_map new
-flat_map optional
-flat_map ratio
-flat_map stdexcept
-flat_map tuple
 flat_map type_traits
-flat_map typeinfo
-flat_map utility
-flat_map variant
 flat_map version
 format algorithm
 format array
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 89c28e49d6c9de..6de95139279471 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -697,35 +697,13 @@ filesystem utility
 filesystem variant
 filesystem vector
 filesystem version
-flat_map atomic
-flat_map cctype
-flat_map climits
 flat_map cmath
 flat_map compare
-flat_map concepts
 flat_map cstddef
 flat_map cstdint
-flat_map cstdio
-flat_map cstdlib
-flat_map cstring
-flat_map ctime
-flat_map cwchar
-flat_map cwctype
-flat_map exception
 flat_map initializer_list
-flat_map iosfwd
-flat_map iterator
 flat_map limits
-flat_map memory
-flat_map new
-flat_map optional
-flat_map ratio
-flat_map stdexcept
-flat_map tuple
 flat_map type_traits
-flat_map typeinfo
-flat_map utility
-flat_map variant
 flat_map version
 format algorithm
 format array

>From 0542e60232c7f7043482e2445dc64ed122a8d01e Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 9 Dec 2024 11:44:15 -0500
Subject: [PATCH 2/2] Also remove __assert as a drive-by

---
 libcxx/include/flat_map | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libcxx/include/flat_map b/libcxx/include/flat_map
index 870dd2e26a2379..71197e32c0b051 100644
--- a/libcxx/include/flat_map
+++ b/libcxx/include/flat_map
@@ -37,7 +37,6 @@ namespace std {
       erase_if(flat_map<Key, T, Compare, KeyContainer, MappedContainer>& c, Predicate pred);
 */
 
-#include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
 
 #if _LIBCPP_STD_VER >= 23



More information about the libcxx-commits mailing list