diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -205,8 +205,8 @@ # define _LIBCPP_COMPILER_IBM #endif -#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L -#error "libc++ does not support using GCC with C++03. Please enable C++11" +#if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L +# error "libc++ does not support compilers other than Clang in C++03. Please enable C++11." #endif // FIXME: ABI detection should be done via compiler builtin macros. This @@ -387,56 +387,47 @@ #endif #ifndef _LIBCPP_CXX03_LANG -# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) -#elif defined(_LIBCPP_COMPILER_CLANG_BASED) -# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) -#else -# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" -#endif - -#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) - -#if defined(_LIBCPP_COMPILER_CLANG_BASED) - -#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ - (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) -# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -#endif -#if __has_feature(cxx_alignas) +# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) # define _ALIGNAS_TYPE(x) alignas(x) # define _ALIGNAS(x) alignas(x) +# define _LIBCPP_NORETURN [[noreturn]] +# define _NOEXCEPT noexcept +# define _NOEXCEPT_(x) noexcept(x) + #else + +# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) # define _ALIGNAS(x) __attribute__((__aligned__(x))) -#endif +# define _LIBCPP_NORETURN __attribute__ ((noreturn)) +# define nullptr __nullptr +# define _NOEXCEPT throw() +# define _NOEXCEPT_(x) -#if __cplusplus < 201103L -typedef __char16_t char16_t; -typedef __char32_t char32_t; -#endif +using char16_t = __char16_t; +using char32_t = __char32_t; -#if !__has_feature(cxx_exceptions) -# define _LIBCPP_NO_EXCEPTIONS #endif -#if __has_feature(cxx_attributes) -# define _LIBCPP_NORETURN [[noreturn]] -#else -# define _LIBCPP_NORETURN __attribute__ ((noreturn)) +#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L +# define _LIBCPP_NO_EXCEPTIONS #endif -#ifdef _LIBCPP_CXX03_LANG -# define nullptr __nullptr -#endif +#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) + +# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ + (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) +# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT +# endif // Objective-C++ features (opt-in) #if __has_feature(objc_arc) -#define _LIBCPP_HAS_OBJC_ARC +# define _LIBCPP_HAS_OBJC_ARC #endif #if __has_feature(objc_arc_weak) -#define _LIBCPP_HAS_OBJC_ARC_WEAK +# define _LIBCPP_HAS_OBJC_ARC_WEAK #endif #if __has_extension(blocks) @@ -447,85 +438,60 @@ # define _LIBCPP_HAS_BLOCKS_RUNTIME #endif -#if !(__has_feature(cxx_noexcept)) -#define _LIBCPP_HAS_NO_NOEXCEPT -#endif - -#if !__has_feature(address_sanitizer) -#define _LIBCPP_HAS_NO_ASAN -#endif - // Allow for build-time disabling of unsigned integer sanitization #if __has_attribute(no_sanitize) -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) +# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) - -#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ +#if defined(_LIBCPP_COMPILER_CLANG_BASED) -#elif defined(_LIBCPP_COMPILER_GCC) +# if !__has_feature(address_sanitizer) +# define _LIBCPP_HAS_NO_ASAN +# endif -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) +# if !(__has_feature(cxx_noexcept)) +# define _LIBCPP_HAS_NO_NOEXCEPT +# endif -#define _LIBCPP_NORETURN __attribute__((noreturn)) +# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) -#if !defined(__EXCEPTIONS) -# define _LIBCPP_NO_EXCEPTIONS -#endif +# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ -#if !defined(__SANITIZE_ADDRESS__) -#define _LIBCPP_HAS_NO_ASAN -#endif +#elif defined(_LIBCPP_COMPILER_GCC) -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# if !defined(__SANITIZE_ADDRESS__) +# define _LIBCPP_HAS_NO_ASAN +# endif -#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ +# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ #elif defined(_LIBCPP_COMPILER_MSVC) -#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) - -#if _MSC_VER < 1900 -#error "MSVC versions prior to Visual Studio 2015 are not supported" -#endif - -#define __alignof__ __alignof -#define _LIBCPP_NORETURN __declspec(noreturn) -#define _ALIGNAS(x) __declspec(align(x)) -#define _ALIGNAS_TYPE(x) alignas(x) - -#define _LIBCPP_WEAK - -#define _LIBCPP_HAS_NO_ASAN +# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) -#define _LIBCPP_ALWAYS_INLINE __forceinline - -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION +# if _MSC_VER < 1900 +# error "MSVC versions prior to Visual Studio 2015 are not supported" +# endif -#define _LIBCPP_DISABLE_EXTENSION_WARNING +# define _LIBCPP_HAS_NO_ASAN +# define _LIBCPP_ALWAYS_INLINE __forceinline +# define _LIBCPP_HAS_NO_VECTOR_EXTENSION +# define _LIBCPP_DISABLE_EXTENSION_WARNING #elif defined(_LIBCPP_COMPILER_IBM) -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) -#define _ATTRIBUTE(x) __attribute__((x)) -#define _LIBCPP_NORETURN __attribute__((noreturn)) - -#define _LIBCPP_HAS_NO_UNICODE_CHARS - -#if defined(_AIX) -#define __MULTILOCALE_API -#endif - -#define _LIBCPP_HAS_NO_ASAN - -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# if defined(_AIX) +# define __MULTILOCALE_API +# endif -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION +# define _LIBCPP_HAS_NO_ASAN +# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# define _LIBCPP_HAS_NO_VECTOR_EXTENSION +# define _LIBCPP_DISABLE_EXTENSION_WARNING -#define _LIBCPP_DISABLE_EXTENSION_WARNING +typedef unsigned short char16_t; +typedef unsigned int char32_t; #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] @@ -733,19 +699,6 @@ # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) #endif -#ifndef _LIBCPP_HAS_NO_NOEXCEPT -# define _NOEXCEPT noexcept -# define _NOEXCEPT_(x) noexcept(x) -#else -# define _NOEXCEPT throw() -# define _NOEXCEPT_(x) -#endif - -#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS -typedef unsigned short char16_t; -typedef unsigned int char32_t; -#endif - #ifndef __SIZEOF_INT128__ #define _LIBCPP_HAS_NO_INT128 #endif @@ -950,12 +903,7 @@ const void *, const void *, const void *, const void *); #endif -// Try to find out if RTTI is disabled. -#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) -# define _LIBCPP_NO_RTTI -#elif defined(__GNUC__) && !defined(__GXX_RTTI) -# define _LIBCPP_NO_RTTI -#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) +#if !defined(__cpp_rtti) || __cpp_rtti < 199711L # define _LIBCPP_NO_RTTI #endif @@ -1122,10 +1070,8 @@ #endif // Use a function like macro to imply that it must be followed by a semicolon -#if _LIBCPP_STD_VER > 14 && __has_cpp_attribute(fallthrough) +#if __has_cpp_attribute(fallthrough) # define _LIBCPP_FALLTHROUGH() [[fallthrough]] -#elif __has_cpp_attribute(clang::fallthrough) -# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] #elif __has_attribute(__fallthrough__) # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) #else @@ -1218,18 +1164,12 @@ #endif #if __has_attribute(init_priority) - // TODO: Remove this once we drop support for building libc++ with old Clangs -# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ - (defined(__apple_build_version__) && __apple_build_version__ < 13000000) -# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) -# else -# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) -# endif +# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) #else -# define _LIBCPP_INIT_PRIORITY_MAX +# define _LIBCPP_INIT_PRIORITY_MAX #endif -#if defined(__GNUC__) || defined(__clang__) +#if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) // The attribute uses 1-based indices for ordinary and static member functions. // The attribute uses 2-based indices for non-static member functions. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \