-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] Temporarily not use compiler intrinsics for some type traits…
… in Objective-C++ mode. Currently, there are bugs in Clang's intrinsics for type traits when handling Objective-C++ `id` (e.g. in `add_pointer`). As a temporary workaround, don't use these intrinsics in the Objective-C++ mode. Differential Revision: https://reviews.llvm.org/D145186 (cherry picked from commit 87cf39a)
- Loading branch information
Showing
4 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
libcxx/test/std/utilities/meta/meta.trans/objc_support.pass.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// REQUIRES: objective-c++ | ||
|
||
// Simple test to check that type traits support Objective-C types. | ||
|
||
#include <type_traits> | ||
#include "test_macros.h" | ||
|
||
@interface I; | ||
@end | ||
|
||
// add_pointer | ||
static_assert(std::is_same<std::add_pointer<id>::type, id*>::value, ""); | ||
static_assert(std::is_same<std::add_pointer<I>::type, I*>::value, ""); | ||
|
||
// add_lvalue_reference | ||
static_assert(std::is_same<std::add_lvalue_reference<id>::type, id&>::value, ""); | ||
static_assert(std::is_same<std::add_lvalue_reference<I>::type, I&>::value, ""); | ||
|
||
// add_rvalue_reference | ||
static_assert(std::is_same<std::add_rvalue_reference<id>::type, id&&>::value, ""); | ||
static_assert(std::is_same<std::add_rvalue_reference<I>::type, I&&>::value, ""); | ||
|
||
// decay | ||
static_assert(std::is_same<std::decay<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::decay<I>::type, I>::value, ""); | ||
static_assert(std::is_same<std::decay<id(&)[5]>::type, id*>::value, ""); | ||
|
||
// __libcpp_is_referenceable | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<id>::value, ""); | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<id*>::value, ""); | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<id&>::value, ""); | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<id&&>::value, ""); | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<I>::value, ""); | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<I*>::value, ""); | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<I&>::value, ""); | ||
LIBCPP_STATIC_ASSERT(std::__libcpp_is_referenceable<I&&>::value, ""); | ||
|
||
// remove_all_extents | ||
static_assert(std::is_same<std::remove_all_extents<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_all_extents<id[5]>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_all_extents<id[5][10]>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_all_extents<I>::type, I>::value, ""); | ||
|
||
// remove_const | ||
static_assert(std::is_same<std::remove_const<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_const<const id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_const<I>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_const<const I>::type, I>::value, ""); | ||
|
||
// remove_cv | ||
static_assert(std::is_same<std::remove_cv<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_cv<const volatile id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_cv<I>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_cv<const volatile I>::type, I>::value, ""); | ||
|
||
#if TEST_STD_VER >= 20 | ||
// remove_cvref | ||
static_assert(std::is_same<std::remove_cvref<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_cvref<const volatile id&>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_cvref<const volatile id&&>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_cvref<I>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_cvref<const volatile I&>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_cvref<const volatile I&&>::type, I>::value, ""); | ||
#endif | ||
|
||
// remove_extent | ||
static_assert(std::is_same<std::remove_all_extents<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_all_extents<id[5]>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_all_extents<I>::type, I>::value, ""); | ||
|
||
// remove_pointer | ||
static_assert(!std::is_same<std::remove_pointer<id>::type, id>::value, ""); | ||
// The result of removing and re-adding pointer to `id` should be still `id`. | ||
static_assert(std::is_same<std::remove_pointer<id>::type*, id>::value, ""); | ||
static_assert(std::is_same<std::add_pointer<std::remove_pointer<id>::type>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_pointer<std::add_pointer<id>::type>::type, id>::value, ""); | ||
|
||
// remove_reference | ||
static_assert(std::is_same<std::remove_reference<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<id&>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<const id&>::type, const id>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<id&&>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<const id&&>::type, const id>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<I>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<I&>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<const I&>::type, const I>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<I&&>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_reference<const I&&>::type, const I>::value, ""); | ||
|
||
// remove_volatile | ||
static_assert(std::is_same<std::remove_volatile<id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_volatile<volatile id>::type, id>::value, ""); | ||
static_assert(std::is_same<std::remove_volatile<I>::type, I>::value, ""); | ||
static_assert(std::is_same<std::remove_volatile<volatile I>::type, I>::value, ""); | ||
|
||
int main(int, char**) { | ||
return 0; | ||
} |