Skip to content

[libc++] Remove transitive <locale> include from <vector> #80282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

philnik777
Copy link
Contributor

This reduces the time to include <vector> from 468ms to 367ms.

@philnik777 philnik777 requested a review from a team as a code owner February 1, 2024 12:09
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Feb 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 1, 2024

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

This reduces the time to include &lt;vector&gt; from 468ms to 367ms.


Full diff: https://github.com/llvm/llvm-project/pull/80282.diff

9 Files Affected:

  • (modified) libcxx/include/__format/formatter_bool.h (+1-1)
  • (modified) libcxx/include/__format/formatter_integral.h (+1-1)
  • (modified) libcxx/include/vector (+1)
  • (modified) libcxx/test/libcxx/transitive_includes/cxx11.csv (+6)
  • (modified) libcxx/test/libcxx/transitive_includes/cxx14.csv (+6)
  • (modified) libcxx/test/libcxx/transitive_includes/cxx17.csv (+6)
  • (modified) libcxx/test/libcxx/transitive_includes/cxx20.csv (+6)
  • (modified) libcxx/test/libcxx/transitive_includes/cxx23.csv (+10-1)
  • (modified) libcxx/test/libcxx/transitive_includes/cxx26.csv (+10-1)
diff --git a/libcxx/include/__format/formatter_bool.h b/libcxx/include/__format/formatter_bool.h
index 1c479501b675f..5e3daff7b3dba 100644
--- a/libcxx/include/__format/formatter_bool.h
+++ b/libcxx/include/__format/formatter_bool.h
@@ -22,7 +22,7 @@
 #include <__utility/unreachable.h>
 
 #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_integral.h b/libcxx/include/__format/formatter_integral.h
index e0217a240027c..eca966f8886f8 100644
--- a/libcxx/include/__format/formatter_integral.h
+++ b/libcxx/include/__format/formatter_integral.h
@@ -32,7 +32,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/vector b/libcxx/include/vector
index e9dd57055cb11..6b0bdb960203c 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -2972,6 +2972,7 @@ _LIBCPP_POP_MACROS
 #  include <atomic>
 #  include <concepts>
 #  include <cstdlib>
+#  include <locale>
 #  include <type_traits>
 #  include <typeinfo>
 #  include <utility>
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 21f0138b1b4bb..5eb839a3aa7a6 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -839,13 +839,17 @@ system_error type_traits
 system_error version
 thread array
 thread atomic
+thread cctype
 thread cerrno
 thread chrono
+thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdlib
 thread cstring
 thread ctime
+thread cwchar
 thread functional
 thread iosfwd
 thread limits
@@ -954,8 +958,10 @@ variant version
 vector algorithm
 vector array
 vector atomic
+vector cctype
 vector cerrno
 vector climits
+vector clocale
 vector compare
 vector concepts
 vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 71d1735d79487..7b372fb37dcd5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -841,13 +841,17 @@ system_error type_traits
 system_error version
 thread array
 thread atomic
+thread cctype
 thread cerrno
 thread chrono
+thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdlib
 thread cstring
 thread ctime
+thread cwchar
 thread functional
 thread iosfwd
 thread limits
@@ -956,8 +960,10 @@ variant version
 vector algorithm
 vector array
 vector atomic
+vector cctype
 vector cerrno
 vector climits
+vector clocale
 vector compare
 vector concepts
 vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 71d1735d79487..7b372fb37dcd5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -841,13 +841,17 @@ system_error type_traits
 system_error version
 thread array
 thread atomic
+thread cctype
 thread cerrno
 thread chrono
+thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdlib
 thread cstring
 thread ctime
+thread cwchar
 thread functional
 thread iosfwd
 thread limits
@@ -956,8 +960,10 @@ variant version
 vector algorithm
 vector array
 vector atomic
+vector cctype
 vector cerrno
 vector climits
+vector clocale
 vector compare
 vector concepts
 vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 4d4372275eb82..9b4915a468d1c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -846,12 +846,16 @@ system_error type_traits
 system_error version
 thread array
 thread atomic
+thread cctype
 thread cerrno
+thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdlib
 thread cstring
 thread ctime
+thread cwchar
 thread functional
 thread iosfwd
 thread limits
@@ -960,8 +964,10 @@ variant version
 vector algorithm
 vector array
 vector atomic
+vector cctype
 vector cerrno
 vector climits
+vector clocale
 vector compare
 vector concepts
 vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 94c67307cc2f1..7c7099d176f18 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -585,11 +585,16 @@ system_error string
 system_error version
 thread array
 thread atomic
+thread cctype
 thread cerrno
+thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdlib
+thread cstring
 thread ctime
+thread cwchar
 thread initializer_list
 thread iosfwd
 thread limits
@@ -601,6 +606,7 @@ thread stdexcept
 thread string
 thread string_view
 thread tuple
+thread typeinfo
 thread version
 tuple compare
 tuple cstddef
@@ -658,20 +664,23 @@ variant new
 variant tuple
 variant version
 vector array
+vector cctype
 vector cerrno
 vector climits
+vector clocale
 vector compare
 vector cstddef
 vector cstdint
+vector cstdlib
 vector cstring
 vector cwchar
 vector initializer_list
 vector iosfwd
 vector limits
-vector locale
 vector new
 vector stdexcept
 vector string
 vector string_view
 vector tuple
+vector typeinfo
 vector version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 94c67307cc2f1..7c7099d176f18 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -585,11 +585,16 @@ system_error string
 system_error version
 thread array
 thread atomic
+thread cctype
 thread cerrno
+thread clocale
 thread compare
 thread cstddef
 thread cstdint
+thread cstdlib
+thread cstring
 thread ctime
+thread cwchar
 thread initializer_list
 thread iosfwd
 thread limits
@@ -601,6 +606,7 @@ thread stdexcept
 thread string
 thread string_view
 thread tuple
+thread typeinfo
 thread version
 tuple compare
 tuple cstddef
@@ -658,20 +664,23 @@ variant new
 variant tuple
 variant version
 vector array
+vector cctype
 vector cerrno
 vector climits
+vector clocale
 vector compare
 vector cstddef
 vector cstdint
+vector cstdlib
 vector cstring
 vector cwchar
 vector initializer_list
 vector iosfwd
 vector limits
-vector locale
 vector new
 vector stdexcept
 vector string
 vector string_view
 vector tuple
+vector typeinfo
 vector version

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the CI green and the clang-tidy change split up elsewhere.

@philnik777 philnik777 force-pushed the remove_locale_include branch from 3436f76 to 5ffbaf6 Compare February 1, 2024 18:33
@philnik777 philnik777 merged commit ffb3589 into llvm:main Feb 2, 2024
@philnik777 philnik777 deleted the remove_locale_include branch February 2, 2024 10:33
agozillon pushed a commit to agozillon/llvm-project that referenced this pull request Feb 5, 2024
This reduces the time to include `<vector>` from 468ms to 367ms.
var-const added a commit to var-const/llvm-project that referenced this pull request Jun 16, 2024
This is a follow-up to llvm#80282.
The transitive includes of `<locale>` in `<vector>` were all guarded by
the availability macro -- the new include should also be guarded,
otherwise any users who compile with localization disabled will start
getting errors trying to include `<vector>`.
ldionne pushed a commit that referenced this pull request Jun 17, 2024
…ro (#95686)

This is a follow-up to #80282.
The transitive includes of `<locale>` in `<vector>` were all guarded by
the availability macro -- the new include should also be guarded,
otherwise any users who compile with localization disabled will start
getting errors trying to include `<vector>`.
blueboxd pushed a commit to blueboxd/libcxx that referenced this pull request Apr 19, 2025
…ro (#95686)

This is a follow-up to llvm/llvm-project#80282.
The transitive includes of `<locale>` in `<vector>` were all guarded by
the availability macro -- the new include should also be guarded,
otherwise any users who compile with localization disabled will start
getting errors trying to include `<vector>`.

NOKEYCHECK=True
GitOrigin-RevId: 0cfdce854d588876bfca7030be868314e84c0e5b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants