cjdb created this revision. cjdb added reviewers: rsmith, aaron.ballman. Herald added a project: All. cjdb requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
The original names apparently broke convention by not making them the same as the C++ type trait names, so we're creating aliases for them. It's unclear whether or not the existing names can be deprecated and removed in the future. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D149492 Files: clang/include/clang/Basic/TokenKinds.def clang/test/SemaCXX/type-traits.cpp
Index: clang/test/SemaCXX/type-traits.cpp =================================================================== --- clang/test/SemaCXX/type-traits.cpp +++ clang/test/SemaCXX/type-traits.cpp @@ -1073,6 +1073,38 @@ static_assert(!__is_nullptr(StructWithMembers), ""); static_assert(!__is_nullptr(int StructWithMembers::*), ""); static_assert(!__is_nullptr(void(StructWithMembers::*)()), ""); + + static_assert(__is_null_pointer(decltype(nullptr)), ""); + static_assert(!__is_null_pointer(void *), ""); + static_assert(!__is_null_pointer(cvoid *), ""); + static_assert(!__is_null_pointer(cvoid *), ""); + static_assert(!__is_null_pointer(char *), ""); + static_assert(!__is_null_pointer(int *), ""); + static_assert(!__is_null_pointer(int **), ""); + static_assert(!__is_null_pointer(ClassType *), ""); + static_assert(!__is_null_pointer(Derives *), ""); + static_assert(!__is_null_pointer(Enum *), ""); + static_assert(!__is_null_pointer(IntArNB *), ""); + static_assert(!__is_null_pointer(Union *), ""); + static_assert(!__is_null_pointer(UnionAr *), ""); + static_assert(!__is_null_pointer(StructWithMembers *), ""); + static_assert(!__is_null_pointer(void (*)()), ""); + + static_assert(!__is_null_pointer(void), ""); + static_assert(!__is_null_pointer(cvoid), ""); + static_assert(!__is_null_pointer(cvoid), ""); + static_assert(!__is_null_pointer(char), ""); + static_assert(!__is_null_pointer(int), ""); + static_assert(!__is_null_pointer(int), ""); + static_assert(!__is_null_pointer(ClassType), ""); + static_assert(!__is_null_pointer(Derives), ""); + static_assert(!__is_null_pointer(Enum), ""); + static_assert(!__is_null_pointer(IntArNB), ""); + static_assert(!__is_null_pointer(Union), ""); + static_assert(!__is_null_pointer(UnionAr), ""); + static_assert(!__is_null_pointer(StructWithMembers), ""); + static_assert(!__is_null_pointer(int StructWithMembers::*), ""); + static_assert(!__is_null_pointer(void(StructWithMembers::*)()), ""); } void is_member_object_pointer() @@ -3534,6 +3566,7 @@ } template <class T> using remove_reference_t = __remove_reference_t(T); +template <class T> using remove_reference = __remove_reference(T); void check_remove_reference() { static_assert(__is_same(remove_reference_t<void>, void), ""); @@ -3568,6 +3601,39 @@ static_assert(__is_same(remove_reference_t<int S::*const volatile &>, int S::*const volatile), ""); static_assert(__is_same(remove_reference_t<int (S::*const volatile &)()>, int(S::*const volatile)()), ""); static_assert(__is_same(remove_reference_t<int (S::*const volatile &&)() &>, int(S::*const volatile)() &), ""); + + static_assert(__is_same(remove_reference<void>, void), ""); + static_assert(__is_same(remove_reference<const volatile void>, const volatile void), ""); + static_assert(__is_same(remove_reference<int>, int), ""); + static_assert(__is_same(remove_reference<const int>, const int), ""); + static_assert(__is_same(remove_reference<volatile int>, volatile int), ""); + static_assert(__is_same(remove_reference<const volatile int>, const volatile int), ""); + static_assert(__is_same(remove_reference<int *>, int *), ""); + static_assert(__is_same(remove_reference<int *const volatile>, int *const volatile), ""); + static_assert(__is_same(remove_reference<int const *const volatile>, int const *const volatile), ""); + static_assert(__is_same(remove_reference<int &>, int), ""); + static_assert(__is_same(remove_reference<int const volatile &>, int const volatile), ""); + static_assert(__is_same(remove_reference<int &&>, int), ""); + static_assert(__is_same(remove_reference<int const volatile &&>, int const volatile), ""); + static_assert(__is_same(remove_reference<int()>, int()), ""); + static_assert(__is_same(remove_reference<int (*const volatile)()>, int (*const volatile)()), ""); + static_assert(__is_same(remove_reference<int (&)()>, int()), ""); + + static_assert(__is_same(remove_reference<S>, S), ""); + static_assert(__is_same(remove_reference<S &>, S), ""); + static_assert(__is_same(remove_reference<S &&>, S), ""); + static_assert(__is_same(remove_reference<const S>, const S), ""); + static_assert(__is_same(remove_reference<const S &>, const S), ""); + static_assert(__is_same(remove_reference<const S &&>, const S), ""); + static_assert(__is_same(remove_reference<volatile S>, volatile S), ""); + static_assert(__is_same(remove_reference<volatile S &>, volatile S), ""); + static_assert(__is_same(remove_reference<volatile S &&>, volatile S), ""); + static_assert(__is_same(remove_reference<const volatile S>, const volatile S), ""); + static_assert(__is_same(remove_reference<const volatile S &>, const volatile S), ""); + static_assert(__is_same(remove_reference<const volatile S &&>, const volatile S), ""); + static_assert(__is_same(remove_reference<int S::*const volatile &>, int S::*const volatile), ""); + static_assert(__is_same(remove_reference<int (S::*const volatile &)()>, int(S::*const volatile)()), ""); + static_assert(__is_same(remove_reference<int (S::*const volatile &&)() &>, int(S::*const volatile)() &), ""); } template <class T> using remove_cvref_t = __remove_cvref(T); Index: clang/include/clang/Basic/TokenKinds.def =================================================================== --- clang/include/clang/Basic/TokenKinds.def +++ clang/include/clang/Basic/TokenKinds.def @@ -517,12 +517,15 @@ #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) KEYWORD(__##Trait, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" +ALIAS("__remove_reference", __remove_reference_t, KEYCXX) + // Clang-only C++ Type Traits TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX) TYPE_TRAIT_1(__is_trivially_equality_comparable, IsTriviallyEqualityComparable, KEYCXX) TYPE_TRAIT_1(__is_bounded_array, IsBoundedArray, KEYCXX) TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX) TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX) +ALIAS("__is_null_pointer", __is_nullptr, KEYCXX) TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX) TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX) TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits