[libcxx-commits] [libcxx] [libc++] Remove <locale> includes from <format> (PR #85478)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 15 15:50:01 PDT 2024
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/85478
>From 41cbca720cb29f085aad844f17af095bdca75baf Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 7 Mar 2024 16:57:42 +0100
Subject: [PATCH] [libc++] Remove <locale> includes from <format>
This reduces the include time from 767ms to 691ms.
---
libcxx/include/__format/format_context.h | 2 +-
libcxx/include/__format/format_functions.h | 2 +-
.../include/__format/formatter_floating_point.h | 2 +-
libcxx/include/format | 4 ++++
libcxx/test/libcxx/transitive_includes/cxx03.csv | 5 +++++
libcxx/test/libcxx/transitive_includes/cxx11.csv | 5 +++++
libcxx/test/libcxx/transitive_includes/cxx14.csv | 5 +++++
libcxx/test/libcxx/transitive_includes/cxx17.csv | 5 +++++
libcxx/test/libcxx/transitive_includes/cxx20.csv | 11 ++++++++++-
libcxx/test/libcxx/transitive_includes/cxx23.csv | 16 ++++++++++++++--
libcxx/test/libcxx/transitive_includes/cxx26.csv | 16 ++++++++++++++--
11 files changed, 65 insertions(+), 8 deletions(-)
diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h
index d131e942aca60b..bf603c5c62d9db 100644
--- a/libcxx/include/__format/format_context.h
+++ b/libcxx/include/__format/format_context.h
@@ -27,7 +27,7 @@
#include <cstddef>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-# include <locale>
+# include <__locale>
# include <optional>
#endif
diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index 3ee53539f4ee6c..c7810140105a07 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -41,7 +41,7 @@
#include <string_view>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-# include <locale>
+# include <__locale>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__format/formatter_floating_point.h b/libcxx/include/__format/formatter_floating_point.h
index f01d323efff5fc..1d94cc349c0dd6 100644
--- a/libcxx/include/__format/formatter_floating_point.h
+++ b/libcxx/include/__format/formatter_floating_point.h
@@ -39,7 +39,7 @@
#include <cstddef>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-# include <locale>
+# include <__locale>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/format b/libcxx/include/format
index c0485c5a103596..146613464534f7 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -221,4 +221,8 @@ namespace std {
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <locale>
+#endif
+
#endif // _LIBCPP_FORMAT
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 678a986e522aa0..c65b9b9d705e27 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -266,9 +266,14 @@ filesystem system_error
filesystem type_traits
filesystem version
format array
+format cctype
+format clocale
format cmath
format cstddef
format cstdint
+format cstdlib
+format cstring
+format cwchar
format initializer_list
format limits
format locale
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index c3875fa2cfc06f..b3d9e327fc7aa9 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -267,9 +267,14 @@ filesystem system_error
filesystem type_traits
filesystem version
format array
+format cctype
+format clocale
format cmath
format cstddef
format cstdint
+format cstdlib
+format cstring
+format cwchar
format initializer_list
format limits
format locale
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index e28e0cd44fed95..d723409422a3eb 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -269,9 +269,14 @@ filesystem system_error
filesystem type_traits
filesystem version
format array
+format cctype
+format clocale
format cmath
format cstddef
format cstdint
+format cstdlib
+format cstring
+format cwchar
format initializer_list
format limits
format locale
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index e28e0cd44fed95..d723409422a3eb 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -269,9 +269,14 @@ filesystem system_error
filesystem type_traits
filesystem version
format array
+format cctype
+format clocale
format cmath
format cstddef
format cstdint
+format cstdlib
+format cstring
+format cwchar
format initializer_list
format limits
format locale
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index eec71f4fc6282e..b355e7b0338b9f 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -113,17 +113,21 @@ charconv type_traits
charconv version
chrono array
chrono bit
+chrono cctype
+chrono cerrno
chrono charconv
+chrono clocale
chrono cmath
chrono compare
chrono concepts
chrono cstddef
chrono cstdint
+chrono cstdlib
chrono cstring
chrono ctime
+chrono cwchar
chrono forward_list
chrono limits
-chrono locale
chrono optional
chrono ostream
chrono ratio
@@ -275,9 +279,14 @@ filesystem system_error
filesystem type_traits
filesystem version
format array
+format cctype
+format clocale
format cmath
format cstddef
format cstdint
+format cstdlib
+format cstring
+format cwchar
format initializer_list
format limits
format locale
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index ccba100af20e90..8150f0935900e4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -68,15 +68,20 @@ charconv limits
charconv new
charconv version
chrono array
+chrono cctype
+chrono cerrno
+chrono clocale
chrono cmath
chrono compare
chrono cstddef
chrono cstdint
+chrono cstdlib
+chrono cstring
chrono ctime
+chrono cwchar
chrono forward_list
chrono initializer_list
chrono limits
-chrono locale
chrono new
chrono optional
chrono ostream
@@ -85,6 +90,8 @@ chrono sstream
chrono stdexcept
chrono string
chrono string_view
+chrono tuple
+chrono typeinfo
chrono vector
chrono version
cinttypes cstdint
@@ -184,12 +191,16 @@ filesystem string
filesystem string_view
filesystem version
format array
+format cctype
+format clocale
format cmath
format cstddef
format cstdint
+format cstdlib
+format cstring
+format cwchar
format initializer_list
format limits
-format locale
format new
format optional
format queue
@@ -198,6 +209,7 @@ format stdexcept
format string
format string_view
format tuple
+format typeinfo
format version
forward_list compare
forward_list cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index ccba100af20e90..8150f0935900e4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -68,15 +68,20 @@ charconv limits
charconv new
charconv version
chrono array
+chrono cctype
+chrono cerrno
+chrono clocale
chrono cmath
chrono compare
chrono cstddef
chrono cstdint
+chrono cstdlib
+chrono cstring
chrono ctime
+chrono cwchar
chrono forward_list
chrono initializer_list
chrono limits
-chrono locale
chrono new
chrono optional
chrono ostream
@@ -85,6 +90,8 @@ chrono sstream
chrono stdexcept
chrono string
chrono string_view
+chrono tuple
+chrono typeinfo
chrono vector
chrono version
cinttypes cstdint
@@ -184,12 +191,16 @@ filesystem string
filesystem string_view
filesystem version
format array
+format cctype
+format clocale
format cmath
format cstddef
format cstdint
+format cstdlib
+format cstring
+format cwchar
format initializer_list
format limits
-format locale
format new
format optional
format queue
@@ -198,6 +209,7 @@ format stdexcept
format string
format string_view
format tuple
+format typeinfo
format version
forward_list compare
forward_list cstddef
More information about the libcxx-commits
mailing list