Skip to content

Commit

Permalink
[clang] Correct the macOS version that supports aligned allocation
Browse files Browse the repository at this point in the history
After checking the libc++abi.dylib shipped in macOS 10.13, I can confirm
that it contains the align_val_t variants of operator new and operator
delete. However, the libc++abi.dylib shipped on macOS 10.12 does not.

Differential Revision: https://reviews.llvm.org/D129198
  • Loading branch information
ldionne committed Jul 6, 2022
1 parent 8366e21 commit 4722b5d
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/AlignedAllocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ inline llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) {
default:
break;
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
return llvm::VersionTuple(10U, 14U);
case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
return llvm::VersionTuple(10U, 13U);
case llvm::Triple::IOS:
case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
return llvm::VersionTuple(11U);
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Driver/unavailable_aligned_allocation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=UNAVAILABLE
//
// RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
Expand Down Expand Up @@ -27,7 +27,7 @@

// UNAVAILABLE: "-faligned-alloc-unavailable"

// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=AVAILABLE
//
// RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
Expand Down Expand Up @@ -57,10 +57,10 @@
// Check that passing -faligned-allocation or -fno-aligned-allocation stops the
// driver from passing -faligned-alloc-unavailable to cc1.
//
// RUN: %clang -target x86_64-apple-macosx10.13 -faligned-allocation -c -### %s 2>&1 \
// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=AVAILABLE
//
// RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c -### %s 2>&1 \
// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=AVAILABLE
//
// RUN: %clang -target s390x-none-zos -faligned-allocation -c -### %s 2>&1 \
Expand Down
12 changes: 6 additions & 6 deletions clang/test/SemaCXX/unavailable_aligned_allocation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
// RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
// RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
// RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
Expand Down Expand Up @@ -120,8 +120,8 @@ void testOveralignedCheckOS() {
// expected-error@-13 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on watchOS 4 or newer}}}
// expected-error@-14 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
#elif defined(MACOS)
// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on macOS 10.14 or newer}}}
// expected-error@-17 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.14 or newer}}}
// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on macOS 10.13 or newer}}}
// expected-error@-17 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}}
#elif defined(ZOS)
// expected-error@-19 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is not available on z/OS}}}
// expected-error@-20 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is not available on z/OS}}}
Expand Down Expand Up @@ -152,7 +152,7 @@ OveralignedS2::~OveralignedS2() {}
// expected-error@-12 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
// expected-note@-13 {{if you supply your own aligned allocation functions}}
#elif defined(MACOS)
// expected-error@-15 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.14 or newer}}}
// expected-error@-15 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}}
// expected-note@-16 {{if you supply your own aligned allocation functions}}
#elif defined(ZOS)
// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is not available on z/OS}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//

// Make sure we get compile-time availability errors when trying to use aligned
// allocation/deallocation on deployment targets that don't support it (before macosx10.14).
// allocation/deallocation on deployment targets that don't support it (before macosx10.13).

// UNSUPPORTED: c++03, c++11, c++14

// Aligned allocation was not provided before macosx10.14.
// REQUIRES: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// Aligned allocation was not provided before macosx10.13.
// REQUIRES: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

#include <new>
#include <cstddef>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// UNSUPPORTED: c++03, c++11, c++14

// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

#include <new>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
// asan and msan will not call the new handler.
// UNSUPPORTED: sanitizer-new-delete

// Aligned allocation was not provided before macosx10.14 and as a result we
// get availability errors when the deployment target is older than macosx10.14.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// Aligned allocation was not provided before macosx10.13 and as a result we
// get availability errors when the deployment target is older than macosx10.13.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

// Libcxx when built for z/OS doesn't contain the aligned allocation functions,
// nor does the dynamic library shipped with z/OS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
// asan and msan will not call the new handler.
// UNSUPPORTED: sanitizer-new-delete

// Aligned allocation was not provided before macosx10.14 and as a result we
// get availability errors when the deployment target is older than macosx10.14.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// Aligned allocation was not provided before macosx10.13 and as a result we
// get availability errors when the deployment target is older than macosx10.13.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

// Libcxx when built for z/OS doesn't contain the aligned allocation functions,
// nor does the dynamic library shipped with z/OS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

// XFAIL: LIBCXX-AIX-FIXME

// Aligned allocation was not provided before macosx10.14 and as a result we
// get availability errors when the deployment target is older than macosx10.14.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// Aligned allocation was not provided before macosx10.13 and as a result we
// get availability errors when the deployment target is older than macosx10.13.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

// Libcxx when built for z/OS doesn't contain the aligned allocation functions,
// nor does the dynamic library shipped with z/OS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

// UNSUPPORTED: c++03, c++11, c++14

// Aligned allocation was not provided before macosx10.14 and as a result we
// get availability errors when the deployment target is older than macosx10.14.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// Aligned allocation was not provided before macosx10.13 and as a result we
// get availability errors when the deployment target is older than macosx10.13.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

// asan and msan will not call the new handler.
// UNSUPPORTED: sanitizer-new-delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

// UNSUPPORTED: c++03, c++11, c++14

// Aligned allocation was not provided before macosx10.14 and as a result we
// get availability errors when the deployment target is older than macosx10.14.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// Aligned allocation was not provided before macosx10.13 and as a result we
// get availability errors when the deployment target is older than macosx10.13.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

// asan and msan will not call the new handler.
// UNSUPPORTED: sanitizer-new-delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

// XFAIL: LIBCXX-AIX-FIXME

// Aligned allocation was not provided before macosx10.14 and as a result we
// get availability errors when the deployment target is older than macosx10.14.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
// Aligned allocation was not provided before macosx10.13 and as a result we
// get availability errors when the deployment target is older than macosx10.13.
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}

// Libcxx when built for z/OS doesn't contain the aligned allocation functions,
// nor does the dynamic library shipped with z/OS.
Expand Down

0 comments on commit 4722b5d

Please sign in to comment.