diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -44,5 +44,10 @@ ABI Changes ----------- +- The ``_LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION`` macro controlling whether we use an + emulation for ``std::nullptr_t`` in C++03 mode has been removed. After this change, + ``_LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION`` will not be honoured anymore and there + will be no way to opt back into the C++03 emulation of ``std::nullptr_t``. + Build System Changes -------------------- diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -276,7 +276,6 @@ __memory/voidify.h __mutex_base __node_handle - __nullptr __numeric/accumulate.h __numeric/adjacent_difference.h __numeric/exclusive_scan.h diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -138,23 +138,6 @@ # endif #endif -// By default, don't use a nullptr_t emulation type in C++03. -// -// This is technically an ABI break from previous releases, however it is -// very unlikely to impact anyone. If a user is impacted by this break, -// they can return to using the C++03 nullptr emulation by defining -// _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION. -// -// This switch will be removed entirely in favour of never providing a -// C++03 emulation after one release. -// -// IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE -// A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN -// IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION. -#ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION -# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR -#endif - #if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 // Enable additional explicit instantiations of iostreams components. This // reduces the number of weak definitions generated in programs that use @@ -534,12 +517,8 @@ # define _LIBCPP_NORETURN __attribute__ ((noreturn)) #endif -#if !(__has_feature(cxx_nullptr)) -# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) -# define nullptr __nullptr -# else -# define _LIBCPP_HAS_NO_NULLPTR -# endif +#ifdef _LIBCPP_CXX03_LANG +# define nullptr __nullptr #endif // Objective-C++ features (opt-in) diff --git a/libcxx/include/__debug b/libcxx/include/__debug --- a/libcxx/include/__debug +++ b/libcxx/include/__debug @@ -18,10 +18,6 @@ # pragma GCC system_header #endif -#if defined(_LIBCPP_HAS_NO_NULLPTR) -# include -#endif - #if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) # include # include diff --git a/libcxx/include/__format/formatter_pointer.h b/libcxx/include/__format/formatter_pointer.h --- a/libcxx/include/__format/formatter_pointer.h +++ b/libcxx/include/__format/formatter_pointer.h @@ -20,7 +20,6 @@ #include <__format/formatter_integral.h> #include <__format/parser_std_format_spec.h> #include <__iterator/access.h> -#include <__nullptr> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/libcxx/include/__memory/auto_ptr.h b/libcxx/include/__memory/auto_ptr.h --- a/libcxx/include/__memory/auto_ptr.h +++ b/libcxx/include/__memory/auto_ptr.h @@ -11,7 +11,6 @@ #define _LIBCPP___MEMORY_AUTO_PTR_H #include <__config> -#include <__nullptr> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__nullptr b/libcxx/include/__nullptr deleted file mode 100644 --- a/libcxx/include/__nullptr +++ /dev/null @@ -1,61 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_NULLPTR -#define _LIBCPP_NULLPTR - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#ifdef _LIBCPP_HAS_NO_NULLPTR - -_LIBCPP_BEGIN_NAMESPACE_STD - -struct _LIBCPP_TEMPLATE_VIS nullptr_t -{ - void* __lx; - - struct __nat {int __for_bool_;}; - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} - - template - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - operator _Tp* () const {return 0;} - - template - _LIBCPP_INLINE_VISIBILITY - operator _Tp _Up::* () const {return 0;} - - friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} -}; - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} - -#define nullptr _VSTD::__get_nullptr_t() - -_LIBCPP_END_NAMESPACE_STD - -#else // _LIBCPP_HAS_NO_NULLPTR - -namespace std -{ - typedef decltype(nullptr) nullptr_t; -} // namespace std - -#endif // _LIBCPP_HAS_NO_NULLPTR - -#endif // _LIBCPP_NULLPTR diff --git a/libcxx/include/__support/win32/locale_win32.h b/libcxx/include/__support/win32/locale_win32.h --- a/libcxx/include/__support/win32/locale_win32.h +++ b/libcxx/include/__support/win32/locale_win32.h @@ -11,7 +11,7 @@ #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H #include <__config> -#include <__nullptr> +#include #include // _locale_t #include diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef --- a/libcxx/include/cstddef +++ b/libcxx/include/cstddef @@ -34,18 +34,16 @@ */ #include <__config> +#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif -// Don't include our own ; we don't want to declare ::nullptr_t. -#include_next -#include <__nullptr> - _LIBCPP_BEGIN_NAMESPACE_STD +using ::nullptr_t; using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS; using ::size_t _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -990,7 +990,6 @@ module __mbstate_t { private header "__mbstate_t.h" export * } module __mutex_base { private header "__mutex_base" export * } module __node_handle { private header "__node_handle" export * } - module __nullptr { header "__nullptr" export * } module __split_buffer { private header "__split_buffer" export * } module __std_stream { private header "__std_stream" export * } module __string { private header "__string" export * } diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h --- a/libcxx/include/stddef.h +++ b/libcxx/include/stddef.h @@ -45,12 +45,7 @@ #include_next #ifdef __cplusplus - -extern "C++" { -#include <__nullptr> -using std::nullptr_t; -} - + typedef decltype(nullptr) nullptr_t; #endif #endif // _LIBCPP_STDDEF_H diff --git a/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp b/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp --- a/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp +++ b/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp @@ -80,14 +80,9 @@ test_conversions(); } { -#ifdef _LIBCPP_HAS_NO_NULLPTR + // TODO: Enable this assertion when GCC compilers implements http://wg21.link/CWG583. +#if !defined(TEST_COMPILER_GCC) static_assert(!has_less::value, ""); - // FIXME: our C++03 nullptr emulation still allows for comparisons - // with other pointer types by way of the conversion operator. - //static_assert(!has_less::value, ""); -#else - // TODO Enable this assertion when all compilers implement core DR 583. - // static_assert(!has_less::value, ""); #endif test_comparisons(); test_comparisons(); diff --git a/libcxx/utils/generate_private_header_tests.py b/libcxx/utils/generate_private_header_tests.py --- a/libcxx/utils/generate_private_header_tests.py +++ b/libcxx/utils/generate_private_header_tests.py @@ -54,8 +54,7 @@ return not rp.startswith('__support') and rp not in [ "__bsd_locale_defaults.h", "__bsd_locale_fallbacks.h", "__config", "__config_site.in", "__debug", "__hash_table", "__functional_base", - "__libcpp_version", "__nullptr", "__threading_support", "__tree", - "__undef_macros" + "__libcpp_version", "__threading_support", "__tree", "__undef_macros" ]