[libc++] Remove the ability to use the std::nullptr_t emulation in C++03 mode

Back in https://reviews.llvm.org/D109459, we stopped using the C++03
emulation for std::nullptr_t by default, which was an ABI break. We
still left a knob for users to turn it back on if they were broken by
the change, with a note that we would remove that knob after one release.

The time has now come to remove the knob and clean up the std::nullptr_t
emulation.

Differential Revision: https://reviews.llvm.org/D114786
This commit is contained in:
Louis Dionne 2021-09-08 12:57:58 -04:00
parent d730336411
commit 157bbe6aea
13 changed files with 14 additions and 112 deletions

View File

@ -44,5 +44,10 @@ API Changes
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
--------------------

View File

@ -276,7 +276,6 @@ set(files
__memory/voidify.h
__mutex_base
__node_handle
__nullptr
__numeric/accumulate.h
__numeric/adjacent_difference.h
__numeric/exclusive_scan.h

View File

@ -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 @@ typedef __char32_t char32_t;
# 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)

View File

@ -18,10 +18,6 @@
# pragma GCC system_header
#endif
#if defined(_LIBCPP_HAS_NO_NULLPTR)
# include <cstddef>
#endif
#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
# include <cstddef>
# include <cstdio>

View File

@ -20,7 +20,6 @@
#include <__format/formatter_integral.h>
#include <__format/parser_std_format_spec.h>
#include <__iterator/access.h>
#include <__nullptr>
#include <cstdint>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View File

@ -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

View File

@ -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 <class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
operator _Tp* () const {return 0;}
template <class _Tp, class _Up>
_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

View File

@ -11,7 +11,7 @@
#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
#include <__config>
#include <__nullptr>
#include <cstddef>
#include <locale.h> // _locale_t
#include <stdio.h>

View File

@ -34,18 +34,16 @@ Types:
*/
#include <__config>
#include <stddef.h>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
#include_next <stddef.h>
#include <__nullptr>
_LIBCPP_BEGIN_NAMESPACE_STD
using ::nullptr_t;
using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
using ::size_t _LIBCPP_USING_IF_EXISTS;

View File

@ -990,7 +990,6 @@ module std [system] {
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 * }

View File

@ -45,12 +45,7 @@ Types:
#include_next <stddef.h>
#ifdef __cplusplus
extern "C++" {
#include <__nullptr>
using std::nullptr_t;
}
typedef decltype(nullptr) nullptr_t;
#endif
#endif // _LIBCPP_STDDEF_H

View File

@ -80,14 +80,9 @@ int main(int, char**)
test_conversions<int A::*>();
}
{
#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<std::nullptr_t>::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<void*>::value, "");
#else
// TODO Enable this assertion when all compilers implement core DR 583.
// static_assert(!has_less<std::nullptr_t>::value, "");
#endif
test_comparisons<std::nullptr_t>();
test_comparisons<void*>();

View File

@ -54,8 +54,7 @@ def is_still_public(path):
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"
]