Skip to content

Commit 233bda0

Browse files
committed
Revert "[libc++] Allow the use of extensions in the implementation (llvm#79532)"
This reverts commit 4d323e4. The heavy use of push/pop directives causes a severe compile-time regression (>50%) when building code that uses libc++ via modules. See discussion on llvm#79532
1 parent c1328db commit 233bda0

File tree

2 files changed

+26
-41
lines changed

2 files changed

+26
-41
lines changed

libcxx/include/__config

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
406406
# define __has_include(...) 0
407407
# endif
408408

409-
# ifndef __has_warning
410-
# define __has_warning(...) 0
411-
# endif
412-
413409
# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
414410
# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
415411
# endif
@@ -727,23 +723,6 @@ typedef __char32_t char32_t;
727723
# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
728724
# endif
729725

730-
# ifdef _LIBCPP_COMPILER_CLANG_BASED
731-
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
732-
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
733-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
734-
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
735-
# elif defined(_LIBCPP_COMPILER_GCC)
736-
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
737-
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
738-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
739-
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
740-
# else
741-
# define _LIBCPP_DIAGNOSTIC_PUSH
742-
# define _LIBCPP_DIAGNOSTIC_POP
743-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
744-
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
745-
# endif
746-
747726
# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
748727
# define _LIBCPP_HARDENING_SIG f
749728
# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
@@ -831,33 +810,16 @@ typedef __char32_t char32_t;
831810
# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
832811
# endif
833812

834-
// TODO: Remove this workaround once we drop support for Clang 16
835-
#if __has_warning("-Wc++23-extensions")
836-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
837-
#else
838-
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions")
839-
#endif
840-
841813
// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
842814
// 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") \
853-
namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
815+
# define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
854816
inline namespace _LIBCPP_ABI_NAMESPACE {
855-
# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_DIAGNOSTIC_POP
817+
# define _LIBCPP_END_NAMESPACE_STD }}
856818

857819
# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
858820
inline namespace __fs { namespace filesystem {
859821

860-
# define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
822+
# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
861823
// clang-format on
862824

863825
# if __has_attribute(__enable_if__)
@@ -1294,6 +1256,23 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
12941256
// the ABI inconsistent.
12951257
# endif
12961258

1259+
# ifdef _LIBCPP_COMPILER_CLANG_BASED
1260+
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1261+
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1262+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1263+
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1264+
# elif defined(_LIBCPP_COMPILER_GCC)
1265+
# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1266+
# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1267+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1268+
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1269+
# else
1270+
# define _LIBCPP_DIAGNOSTIC_PUSH
1271+
# define _LIBCPP_DIAGNOSTIC_POP
1272+
# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1273+
# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1274+
# endif
1275+
12971276
// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
12981277
// functions is gradually being added to existing C libraries. The conditions
12991278
// below check for known C library versions and conditions under which these

libcxx/include/tuple

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ class _LIBCPP_TEMPLATE_VIS tuple {
540540
public:
541541
// [tuple.cnstr]
542542

543+
_LIBCPP_DIAGNOSTIC_PUSH
544+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
545+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
546+
543547
// tuple() constructors (including allocator_arg_t variants)
544548
template <template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
545549
template <class...> class _IsDefault = is_default_constructible,
@@ -821,6 +825,8 @@ public:
821825
: __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
822826
# endif // _LIBCPP_STD_VER >= 23
823827

828+
_LIBCPP_DIAGNOSTIC_POP
829+
824830
// [tuple.assign]
825831
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
826832
operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)

0 commit comments

Comments
 (0)