Skip to content

Commit f886dfe

Browse files
authored
[libc++] Don't push and pop extensions diagnostics when using clang modules (#85917)
Clang modules take a significant compile time hit when pushing and popping diagnostics. Since all the headers are marked as system headers in the modulemap, we can simply disable this pushing and popping when building with clang modules.
1 parent d365a45 commit f886dfe

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

libcxx/include/__config

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -838,21 +838,33 @@ typedef __char32_t char32_t;
838838
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions")
839839
#endif
840840

841+
// Clang modules take a significant compile time hit when pushing and popping diagnostics.
842+
// Since all the headers are marked as system headers in the modulemap, we can simply disable this
843+
// pushing and popping when building with clang modules.
844+
# if !__has_feature(modules)
845+
# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
846+
_LIBCPP_DIAGNOSTIC_PUSH \
847+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
848+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
849+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
850+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
851+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \
852+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
853+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
854+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
855+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
856+
# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP
857+
# else
858+
# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS
859+
# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
860+
# endif
861+
841862
// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
842863
// clang-format off
843-
# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_DIAGNOSTIC_PUSH \
844-
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
845-
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
846-
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
847-
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
848-
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \
849-
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
850-
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
851-
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
852-
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \
864+
# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
853865
namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
854866
inline namespace _LIBCPP_ABI_NAMESPACE {
855-
# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_DIAGNOSTIC_POP
867+
# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS
856868

857869
# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
858870
inline namespace __fs { namespace filesystem {

0 commit comments

Comments
 (0)