[libcxx-commits] [libcxx] r352647 - [libc++] Don't define operator new/delete when using vcruntime

Thomas Anderson via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 30 11:08:33 PST 2019


Author: thomasanderson
Date: Wed Jan 30 11:08:32 2019
New Revision: 352647

URL: http://llvm.org/viewvc/llvm-project?rev=352647&view=rev
Log:
[libc++] Don't define operator new/delete when using vcruntime

Fixes build errors on Windows without libc++abi of the form:

    new(173,36):  error: redeclaration of 'operator delete' cannot add 'dllexport' attribute
    _LIBCPP_OVERRIDABLE_FUNC_VIS void  operator delete(void* __p) _NOEXCEPT;
    vcruntime_new.h(87,16):  note: previous declaration is here
    void __CRTDECL operator delete(
    new(205,70):  error: redefinition of 'operator new'
    _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new  (std::size_t, void* __p) _NOEXCEPT {return __p;}
    vcruntime_new.h(184,28):  note: previous definition is here
        inline void* __CRTDECL operator new(size_t _Size, _Writable_bytes_(_Size) void* _Where) noexcept
    new(206,70):  error: redefinition of 'operator new[]'
    _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}
    vcruntime_new.h(199,28):  note: previous definition is here
        inline void* __CRTDECL operator new[](size_t _Size,
    new(207,40):  error: redefinition of 'operator delete'
    inline _LIBCPP_INLINE_VISIBILITY void  operator delete  (void*, void*) _NOEXCEPT {}
    vcruntime_new.h(190,27):  note: previous definition is here
        inline void __CRTDECL operator delete(void*, void*) noexcept
    new(208,40):  error: redefinition of 'operator delete[]'
    inline _LIBCPP_INLINE_VISIBILITY void  operator delete[](void*, void*) _NOEXCEPT {}
    vcruntime_new.h(206,27):  note: previous definition is here
        inline void __CRTDECL operator delete[](void*, void*) noexcept

Differential Revision: https://reviews.llvm.org/D57362

Modified:
    libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=352647&r1=352646&r2=352647&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Jan 30 11:08:32 2019
@@ -985,17 +985,18 @@ template <unsigned> struct __static_asse
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
 
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
+#  define _LIBCPP_DEFER_NEW_TO_VCRUNTIME
+#endif
+
 // If we are getting operator new from the MSVC CRT, then allocation overloads
 // for align_val_t were added in 19.12, aka VS 2017 version 15.3.
 #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
 #  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-#elif defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
-#  define _LIBCPP_DEFER_NEW_TO_VCRUNTIME
-#  if !defined(__cpp_aligned_new)
-     // We're defering to Microsoft's STL to provide aligned new et al. We don't
-     // have it unless the language feature test macro is defined.
-#    define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-#  endif
+#elif defined(_LIBCPP_DEFER_NEW_TO_VCRUNTIME) && !defined(__cpp_aligned_new)
+   // We're defering to Microsoft's STL to provide aligned new et al. We don't
+   // have it unless the language feature test macro is defined.
+#  define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
 #endif
 
 #if defined(__APPLE__)




More information about the libcxx-commits mailing list