Merged to 7.0 in r339661.
On Fri, Aug 10, 2018 at 3:24 PM, Louis Dionne via cfe-commits <cfe-commits@lists.llvm.org> wrote: > Author: ldionne > Date: Fri Aug 10 06:24:56 2018 > New Revision: 339431 > > URL: http://llvm.org/viewvc/llvm-project?rev=339431&view=rev > Log: > [libc++] Enable aligned allocation based on feature test macro, irrespective > of standard > > Summary: > The current code enables aligned allocation functions when compiling in C++17 > and later. This is a problem because aligned allocation functions might not > be supported on the target platform, which leads to an error at link time. > > Since r338934, Clang knows not to define __cpp_aligned_new when it's not > available on the target platform -- this commit takes advantage of that to > only use aligned allocation functions when they are available. > > Reviewers: vsapsai, EricWF > > Subscribers: christof, dexonsmith, cfe-commits, EricWF, mclow.lists > > Differential Revision: https://reviews.llvm.org/D50344 > > Added: > libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp > Modified: > libcxx/trunk/include/__config > libcxx/trunk/include/new > > Modified: libcxx/trunk/include/__config > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=339431&r1=339430&r2=339431&view=diff > ============================================================================== > --- libcxx/trunk/include/__config (original) > +++ libcxx/trunk/include/__config Fri Aug 10 06:24:56 2018 > @@ -988,6 +988,11 @@ template <unsigned> struct __static_asse > # endif > #endif // defined(__APPLE__) > > +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ > + !defined(_LIBCPP_BUILDING_LIBRARY) && \ > + (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) > +# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION > +#endif > > #if defined(__APPLE__) || defined(__FreeBSD__) > #define _LIBCPP_HAS_DEFAULTRUNELOCALE > > Modified: libcxx/trunk/include/new > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=339431&r1=339430&r2=339431&view=diff > ============================================================================== > --- libcxx/trunk/include/new (original) > +++ libcxx/trunk/include/new Fri Aug 10 06:24:56 2018 > @@ -108,13 +108,6 @@ void operator delete[](void* ptr, void* > # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION > #endif > > -#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ > - (!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \ > - (defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606))) > -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION > -#endif > - > - > #if !__has_builtin(__builtin_operator_new) || \ > __has_builtin(__builtin_operator_new) < 201802L || \ > defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \ > > Added: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp?rev=339431&view=auto > ============================================================================== > --- libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp (added) > +++ libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp Fri Aug > 10 06:24:56 2018 > @@ -0,0 +1,25 @@ > +//===----------------------------------------------------------------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is dual licensed under the MIT and the University of Illinois > Open > +// Source Licenses. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +// UNSUPPORTED: c++98, c++03, c++11, c++14 > +// XFAIL: with_system_cxx_lib=macosx10.12 > +// XFAIL: with_system_cxx_lib=macosx10.11 > +// XFAIL: with_system_cxx_lib=macosx10.10 > +// XFAIL: with_system_cxx_lib=macosx10.9 > +// XFAIL: with_system_cxx_lib=macosx10.8 > +// XFAIL: with_system_cxx_lib=macosx10.7 > + > +#include <new> > + > + > +#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION > +# error "libc++ should have aligned allocation in C++17 and up when > targeting a platform that supports it" > +#endif > + > +int main() { } > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits