cjdb updated this revision to Diff 465285. cjdb edited the summary of this revision. cjdb added a comment.
rewords commit message Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135238/new/ https://reviews.llvm.org/D135238 Files: clang/include/clang/Basic/TokenKinds.def clang/lib/Parse/ParseDeclCXX.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/test/SemaCXX/deprecated-builtins.cpp 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 @@ -1637,8 +1637,8 @@ typedef const IntAr ConstIntAr; typedef ConstIntAr ConstIntArAr[4]; -struct HasCopy { - HasCopy(HasCopy& cp); +struct HasMutableCopyCtor { + HasMutableCopyCtor(HasMutableCopyCtor &cp); }; struct HasMove { @@ -1674,7 +1674,7 @@ { int arr[F(__has_trivial_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}} { int arr[F(__has_trivial_constructor(HasCons))]; } { int arr[F(__has_trivial_constructor(HasRef))]; } - { int arr[F(__has_trivial_constructor(HasCopy))]; } + { int arr[F(__has_trivial_constructor(HasMutableCopyCtor))]; } { int arr[F(__has_trivial_constructor(IntRef))]; } { int arr[F(__has_trivial_constructor(VirtAr))]; } { int arr[F(__has_trivial_constructor(void))]; } @@ -1737,7 +1737,7 @@ { int arr[T(__has_trivial_copy(ACompleteType[]))]; } { int arr[F(__has_trivial_copy(AnIncompleteType[]))]; } // expected-error {{incomplete type}} - { int arr[F(__has_trivial_copy(HasCopy))]; } + { int arr[F(__has_trivial_copy(HasMutableCopyCtor))]; } { int arr[F(__has_trivial_copy(HasTemplateCons))]; } { int arr[F(__has_trivial_copy(VirtAr))]; } { int arr[F(__has_trivial_copy(void))]; } @@ -1757,7 +1757,7 @@ { int arr[T(__has_trivial_assign(HasPriv))]; } { int arr[T(__has_trivial_assign(HasCons))]; } { int arr[T(__has_trivial_assign(HasRef))]; } - { int arr[T(__has_trivial_assign(HasCopy))]; } + { int arr[T(__has_trivial_assign(HasMutableCopyCtor))]; } { int arr[T(__has_trivial_assign(HasMove))]; } { int arr[T(__has_trivial_assign(HasMoveAssign))]; } { int arr[T(__has_trivial_assign(AllDefaulted))]; } @@ -1791,7 +1791,7 @@ { int arr[T(__has_trivial_destructor(HasPriv))]; } { int arr[T(__has_trivial_destructor(HasCons))]; } { int arr[T(__has_trivial_destructor(HasRef))]; } - { int arr[T(__has_trivial_destructor(HasCopy))]; } + { int arr[T(__has_trivial_destructor(HasMutableCopyCtor))]; } { int arr[T(__has_trivial_destructor(HasMove))]; } { int arr[T(__has_trivial_destructor(IntRef))]; } { int arr[T(__has_trivial_destructor(HasCopyAssign))]; } @@ -1848,7 +1848,7 @@ { int arr[T(__has_nothrow_assign(HasPriv))]; } { int arr[T(__has_nothrow_assign(HasCons))]; } { int arr[T(__has_nothrow_assign(HasRef))]; } - { int arr[T(__has_nothrow_assign(HasCopy))]; } + { int arr[T(__has_nothrow_assign(HasMutableCopyCtor))]; } { int arr[T(__has_nothrow_assign(HasMove))]; } { int arr[T(__has_nothrow_assign(HasMoveAssign))]; } { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; } @@ -1957,7 +1957,7 @@ { int arr[T(__has_nothrow_copy(ACompleteType[]))]; } { int arr[F(__has_nothrow_copy(AnIncompleteType[]))]; } // expected-error {{incomplete type}} - { int arr[F(__has_nothrow_copy(HasCopy))]; } + { int arr[F(__has_nothrow_copy(HasMutableCopyCtor))]; } { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; } { int arr[F(__has_nothrow_copy(VirtAr))]; } { int arr[F(__has_nothrow_copy(void))]; } @@ -1987,7 +1987,7 @@ { int arr[F(__has_nothrow_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}} { int arr[F(__has_nothrow_constructor(HasCons))]; } { int arr[F(__has_nothrow_constructor(HasRef))]; } - { int arr[F(__has_nothrow_constructor(HasCopy))]; } + { int arr[F(__has_nothrow_constructor(HasMutableCopyCtor))]; } { int arr[F(__has_nothrow_constructor(HasMove))]; } { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; } { int arr[F(__has_nothrow_constructor(IntRef))]; } @@ -2014,7 +2014,7 @@ { int arr[F(__has_virtual_destructor(HasPriv))]; } { int arr[F(__has_virtual_destructor(HasCons))]; } { int arr[F(__has_virtual_destructor(HasRef))]; } - { int arr[F(__has_virtual_destructor(HasCopy))]; } + { int arr[F(__has_virtual_destructor(HasMutableCopyCtor))]; } { int arr[F(__has_virtual_destructor(HasMove))]; } { int arr[F(__has_virtual_destructor(HasCopyAssign))]; } { int arr[F(__has_virtual_destructor(HasMoveAssign))]; } @@ -2481,6 +2481,390 @@ { int arr[F(__is_nothrow_constructible(const volatile void))]; } } +struct VolatileCopyCtor { + VolatileCopyCtor(volatile VolatileCopyCtor &); +}; + +struct CVCopyCtor { + CVCopyCtor(const volatile CVCopyCtor &); +}; + +struct CopyCtorDeleted { + CopyCtorDeleted(const CopyCtorDeleted &) = delete; +}; + +struct BaseDeletedCopyCtor : CopyCtorDeleted {}; + +struct MemberDeletedCopyCtor { + CopyCtorDeleted x; +}; + +struct NothrowCopyConstructible { + NothrowCopyConstructible(NothrowCopyConstructible const&) noexcept; +}; + +void copy_constructible_checks() { + // Builtin types + + static_assert(__is_copy_constructible(int), ""); + static_assert(__is_nothrow_copy_constructible(int), ""); + static_assert(__is_trivially_copy_constructible(int), ""); + + static_assert(__is_copy_constructible(const int), ""); + static_assert(__is_nothrow_copy_constructible(const int), ""); + static_assert(__is_trivially_copy_constructible(const int), ""); + + static_assert(__is_copy_constructible(volatile int), ""); + static_assert(__is_nothrow_copy_constructible(volatile int), ""); + static_assert(__is_trivially_copy_constructible(volatile int), ""); + + static_assert(__is_copy_constructible(const volatile int), ""); + static_assert(__is_nothrow_copy_constructible(const volatile int), ""); + static_assert(__is_trivially_copy_constructible(const volatile int), ""); + + static_assert(__is_copy_constructible(int&), ""); + static_assert(__is_nothrow_copy_constructible(int&), ""); + static_assert(__is_trivially_copy_constructible(int&), ""); + + static_assert(__is_copy_constructible(const int&), ""); + static_assert(__is_nothrow_copy_constructible(const int&), ""); + static_assert(__is_trivially_copy_constructible(const int&), ""); + + static_assert(__is_copy_constructible(volatile int&), ""); + static_assert(__is_nothrow_copy_constructible(volatile int&), ""); + static_assert(__is_trivially_copy_constructible(volatile int&), ""); + + static_assert(__is_copy_constructible(const volatile int&), ""); + static_assert(__is_nothrow_copy_constructible(const volatile int&), ""); + static_assert(__is_trivially_copy_constructible(const volatile int&), ""); + + static_assert(!__is_copy_constructible(int&&), ""); + static_assert(!__is_nothrow_copy_constructible(int&&), ""); + static_assert(!__is_trivially_copy_constructible(int&&), ""); + + static_assert(!__is_copy_constructible(const int&&), ""); + static_assert(!__is_nothrow_copy_constructible(const int&&), ""); + static_assert(!__is_trivially_copy_constructible(const int&&), ""); + + static_assert(!__is_copy_constructible(volatile int&&), ""); + static_assert(!__is_nothrow_copy_constructible(volatile int&&), ""); + static_assert(!__is_trivially_copy_constructible(volatile int&&), ""); + + static_assert(!__is_copy_constructible(const volatile int&&), ""); + static_assert(!__is_nothrow_copy_constructible(const volatile int&&), ""); + static_assert(!__is_trivially_copy_constructible(const volatile int&&), ""); + + static_assert(__is_copy_constructible(int*), ""); + static_assert(__is_nothrow_copy_constructible(int*), ""); + static_assert(__is_trivially_copy_constructible(int*), ""); + + static_assert(__is_copy_constructible(int* const), ""); + static_assert(__is_nothrow_copy_constructible(int* const), ""); + static_assert(__is_trivially_copy_constructible(int* const), ""); + + static_assert(__is_copy_constructible(int* volatile), ""); + static_assert(__is_nothrow_copy_constructible(int* volatile), ""); + static_assert(__is_trivially_copy_constructible(int* volatile), ""); + + static_assert(__is_copy_constructible(int* const volatile), ""); + static_assert(__is_nothrow_copy_constructible(int* const volatile), ""); + static_assert(__is_trivially_copy_constructible(int* const volatile), ""); + + static_assert(!__is_copy_constructible(int[2]), ""); + static_assert(!__is_nothrow_copy_constructible(int[2]), ""); + static_assert(!__is_trivially_copy_constructible(int[2]), ""); + + static_assert(!__is_copy_constructible(int[]), ""); + static_assert(!__is_nothrow_copy_constructible(int[]), ""); + static_assert(!__is_trivially_copy_constructible(int[]), ""); + + static_assert(__is_copy_constructible(decltype(nullptr)), ""); + static_assert(__is_nothrow_copy_constructible(decltype(nullptr)), ""); + static_assert(__is_trivially_copy_constructible(decltype(nullptr)), ""); + + static_assert(__is_copy_constructible(void(*)()), ""); + static_assert(__is_nothrow_copy_constructible(void(*)()), ""); + static_assert(__is_trivially_copy_constructible(void(*)()), ""); + + static_assert(__is_copy_constructible(void(&)()), ""); + static_assert(__is_nothrow_copy_constructible(void(&)()), ""); + static_assert(__is_trivially_copy_constructible(void(&)()), ""); + + static_assert(__is_copy_constructible(int Empty::*), ""); + static_assert(__is_nothrow_copy_constructible(int Empty::*), ""); + static_assert(__is_trivially_copy_constructible(int Empty::*), ""); + + static_assert(__is_copy_constructible(int (Empty::*)()), ""); + static_assert(__is_nothrow_copy_constructible(int (Empty::*)()), ""); + static_assert(__is_trivially_copy_constructible(int (Empty::*)()), ""); + + // User-defined types + static_assert(__is_copy_constructible(AllDefaulted), ""); + static_assert(__is_nothrow_copy_constructible(AllDefaulted), ""); + static_assert(__is_trivially_copy_constructible(AllDefaulted), ""); + + static_assert(__is_copy_constructible(const AllDefaulted), ""); + static_assert(__is_nothrow_copy_constructible(const AllDefaulted), ""); + static_assert(__is_trivially_copy_constructible(const AllDefaulted), ""); + + static_assert(!__is_copy_constructible(volatile AllDefaulted), ""); + static_assert(!__is_nothrow_copy_constructible(volatile AllDefaulted), ""); + static_assert(!__is_trivially_copy_constructible(volatile AllDefaulted), ""); + + static_assert(!__is_copy_constructible(const volatile AllDefaulted), ""); + static_assert(!__is_nothrow_copy_constructible(const volatile AllDefaulted), ""); + static_assert(!__is_trivially_copy_constructible(const volatile AllDefaulted), ""); + + static_assert(__is_copy_constructible(CEmptyStruct), ""); + static_assert(__is_nothrow_copy_constructible(CEmptyStruct), ""); + static_assert(__is_trivially_copy_constructible(CEmptyStruct), ""); + + static_assert(__is_copy_constructible(CppEmptyStruct), ""); + static_assert(__is_nothrow_copy_constructible(CppEmptyStruct), ""); + static_assert(__is_trivially_copy_constructible(CppEmptyStruct), ""); + + static_assert(__is_copy_constructible(CppStructNonStandardBy2ndVirtBase), ""); + static_assert(__is_nothrow_copy_constructible(CppStructNonStandardBy2ndVirtBase), ""); + static_assert(__is_trivially_copy_constructible(CppStructNonStandardBy2ndVirtBase), ""); + + static_assert(__is_copy_constructible(CppStructNonStandardByBase), ""); + static_assert(__is_nothrow_copy_constructible(CppStructNonStandardByBase), ""); + static_assert(__is_trivially_copy_constructible(CppStructNonStandardByBase), ""); + + static_assert(__is_copy_constructible(CppStructNonStandardByMemb), ""); + static_assert(__is_nothrow_copy_constructible(CppStructNonStandardByMemb), ""); + static_assert(!__is_trivially_copy_constructible(CppStructNonStandardByMemb), ""); + + static_assert(__is_copy_constructible(CppStructNonStandardByProt), ""); + static_assert(__is_nothrow_copy_constructible(CppStructNonStandardByProt), ""); + static_assert(__is_trivially_copy_constructible(CppStructNonStandardByProt), ""); + + static_assert(__is_copy_constructible(CppStructNonStandardBySameBase), ""); + static_assert(__is_nothrow_copy_constructible(CppStructNonStandardBySameBase), ""); + static_assert(__is_trivially_copy_constructible(CppStructNonStandardBySameBase), ""); + + static_assert(__is_copy_constructible(CppStructNonStandardByVirt), ""); + static_assert(__is_nothrow_copy_constructible(CppStructNonStandardByVirt), ""); + static_assert(!__is_trivially_copy_constructible(CppStructNonStandardByVirt), ""); + + static_assert(__is_copy_constructible(CppStructNonStandardByVirtBase), ""); + static_assert(__is_nothrow_copy_constructible(CppStructNonStandardByVirtBase), ""); + static_assert(!__is_trivially_copy_constructible(CppStructNonStandardByVirtBase), ""); + + static_assert(__is_copy_constructible(CppStructStandard), ""); + static_assert(__is_nothrow_copy_constructible(CppStructStandard), ""); + static_assert(__is_trivially_copy_constructible(CppStructStandard), ""); + + static_assert(__is_copy_constructible(CStruct), ""); + static_assert(__is_nothrow_copy_constructible(CStruct), ""); + static_assert(__is_trivially_copy_constructible(CStruct), ""); + + static_assert(__is_copy_constructible(CVCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(CVCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(CVCopyCtor), ""); + + static_assert(__is_copy_constructible(const CVCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(const CVCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(const CVCopyCtor), ""); + + static_assert(__is_copy_constructible(volatile CVCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(volatile CVCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(volatile CVCopyCtor), ""); + + static_assert(__is_copy_constructible(const volatile CVCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(const volatile CVCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(const volatile CVCopyCtor), ""); + + static_assert(__is_copy_constructible(Derives), ""); + static_assert(__is_nothrow_copy_constructible(Derives), ""); + static_assert(__is_trivially_copy_constructible(Derives), ""); + + static_assert(__is_copy_constructible(DerivesHasRef), ""); + static_assert(__is_nothrow_copy_constructible(DerivesHasRef), ""); + static_assert(__is_trivially_copy_constructible(DerivesHasRef), ""); + + static_assert(__is_copy_constructible(Empty), ""); + static_assert(__is_nothrow_copy_constructible(Empty), ""); + static_assert(__is_trivially_copy_constructible(Empty), ""); + + static_assert(__is_copy_constructible(EmptyUnion), ""); + static_assert(__is_nothrow_copy_constructible(EmptyUnion), ""); + static_assert(__is_trivially_copy_constructible(EmptyUnion), ""); + + static_assert(__is_copy_constructible(Enum), ""); + static_assert(__is_nothrow_copy_constructible(Enum), ""); + static_assert(__is_trivially_copy_constructible(Enum), ""); + + static_assert(__is_copy_constructible(const Enum), ""); + static_assert(__is_nothrow_copy_constructible(const Enum), ""); + static_assert(__is_trivially_copy_constructible(const Enum), ""); + + static_assert(__is_copy_constructible(volatile Enum), ""); + static_assert(__is_nothrow_copy_constructible(volatile Enum), ""); + static_assert(__is_trivially_copy_constructible(volatile Enum), ""); + + static_assert(__is_copy_constructible(const volatile Enum), ""); + static_assert(__is_nothrow_copy_constructible(const volatile Enum), ""); + static_assert(__is_trivially_copy_constructible(const volatile Enum), ""); + + static_assert(__is_copy_constructible(EnumClass), ""); + static_assert(__is_nothrow_copy_constructible(EnumClass), ""); + static_assert(__is_trivially_copy_constructible(EnumClass), ""); + + static_assert(__is_copy_constructible(const EnumClass), ""); + static_assert(__is_nothrow_copy_constructible(const EnumClass), ""); + static_assert(__is_trivially_copy_constructible(const EnumClass), ""); + + static_assert(__is_copy_constructible(volatile EnumClass), ""); + static_assert(__is_nothrow_copy_constructible(volatile EnumClass), ""); + static_assert(__is_trivially_copy_constructible(volatile EnumClass), ""); + + static_assert(__is_copy_constructible(const volatile EnumClass), ""); + static_assert(__is_nothrow_copy_constructible(const volatile EnumClass), ""); + static_assert(__is_trivially_copy_constructible(const volatile EnumClass), ""); + + static_assert(__is_copy_constructible(ExtDefaulted), ""); + static_assert(!__is_nothrow_copy_constructible(ExtDefaulted), ""); + static_assert(!__is_trivially_copy_constructible(ExtDefaulted), ""); + + static_assert(__is_copy_constructible(ExtDefaulted), ""); + static_assert(!__is_nothrow_copy_constructible(ExtDefaulted), ""); + static_assert(!__is_trivially_copy_constructible(ExtDefaulted), ""); + + static_assert(__is_copy_constructible(HasCons), ""); + static_assert(__is_nothrow_copy_constructible(HasCons), ""); + static_assert(__is_trivially_copy_constructible(HasCons), ""); + + static_assert(__is_copy_constructible(HasCopyAssign), ""); + static_assert(__is_nothrow_copy_constructible(HasCopyAssign), ""); + static_assert(__is_trivially_copy_constructible(HasCopyAssign), ""); + + static_assert(__is_copy_constructible(HasDest), ""); + static_assert(__is_nothrow_copy_constructible(HasDest), ""); + static_assert(!__is_trivially_copy_constructible(HasDest), ""); + + static_assert(__is_copy_constructible(HasMultipleCopy), ""); + static_assert(__is_nothrow_copy_constructible(HasMultipleCopy), ""); + static_assert(!__is_trivially_copy_constructible(HasMultipleCopy), ""); + + static_assert(__is_copy_constructible(HasPriv), ""); + static_assert(__is_nothrow_copy_constructible(HasPriv), ""); + static_assert(__is_trivially_copy_constructible(HasPriv), ""); + + static_assert(__is_copy_constructible(HasRef), ""); + static_assert(__is_nothrow_copy_constructible(HasRef), ""); + static_assert(__is_trivially_copy_constructible(HasRef), ""); + + static_assert(__is_copy_constructible(HasTemplateCons), ""); + static_assert(__is_nothrow_copy_constructible(HasTemplateCons), ""); + static_assert(!__is_trivially_copy_constructible(HasTemplateCons), ""); + + static_assert(__is_copy_constructible(const HasTemplateCons), ""); + static_assert(__is_nothrow_copy_constructible(const HasTemplateCons), ""); + static_assert(!__is_trivially_copy_constructible(const HasTemplateCons), ""); + + static_assert(__is_copy_constructible(volatile HasTemplateCons), ""); + static_assert(!__is_nothrow_copy_constructible(volatile HasTemplateCons), ""); + static_assert(!__is_trivially_copy_constructible(volatile HasTemplateCons), ""); + + static_assert(__is_copy_constructible(const volatile HasTemplateCons), ""); + static_assert(!__is_nothrow_copy_constructible(const volatile HasTemplateCons), ""); + static_assert(!__is_trivially_copy_constructible(const volatile HasTemplateCons), ""); + + static_assert(__is_copy_constructible(NoDefaultMoveAssignDueToDtor), ""); + static_assert(__is_nothrow_copy_constructible(NoDefaultMoveAssignDueToDtor), ""); + static_assert(!__is_trivially_copy_constructible(NoDefaultMoveAssignDueToDtor), ""); + + static_assert(__is_copy_constructible(NoDefaultMoveAssignDueToUDCopyAssign), ""); + static_assert(__is_nothrow_copy_constructible(NoDefaultMoveAssignDueToUDCopyAssign), ""); + static_assert(__is_trivially_copy_constructible(NoDefaultMoveAssignDueToUDCopyAssign), ""); + + static_assert(__is_copy_constructible(NoDefaultMoveAssignDueToUDCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(NoDefaultMoveAssignDueToUDCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(NoDefaultMoveAssignDueToUDCopyCtor), ""); + + static_assert(__is_copy_constructible(NonTCStruct), ""); + static_assert(!__is_nothrow_copy_constructible(NonTCStruct), ""); + static_assert(!__is_trivially_copy_constructible(NonTCStruct), ""); + + static_assert(__is_copy_constructible(NonTrivialStruct), ""); + static_assert(__is_nothrow_copy_constructible(NonTrivialStruct), ""); + static_assert(__is_trivially_copy_constructible(NonTrivialStruct), ""); + + static_assert(__is_copy_constructible(SuperNonTrivialStruct), ""); + static_assert(__is_nothrow_copy_constructible(SuperNonTrivialStruct), ""); + static_assert(!__is_trivially_copy_constructible(SuperNonTrivialStruct), ""); + + static_assert(__is_copy_constructible(TrivialStruct), ""); + static_assert(__is_nothrow_copy_constructible(TrivialStruct), ""); + static_assert(__is_trivially_copy_constructible(TrivialStruct), ""); + + static_assert(__is_copy_constructible(Union), ""); + static_assert(__is_nothrow_copy_constructible(Union), ""); + static_assert(__is_trivially_copy_constructible(Union), ""); + + static_assert(__is_copy_constructible(NothrowCopyConstructible), ""); + static_assert(__is_nothrow_copy_constructible(NothrowCopyConstructible), ""); + static_assert(!__is_trivially_copy_constructible(NothrowCopyConstructible), ""); + + static_assert(!__is_copy_constructible(AllDeleted), ""); + static_assert(!__is_nothrow_copy_constructible(AllDeleted), ""); + static_assert(!__is_trivially_copy_constructible(AllDeleted), ""); + + static_assert(!__is_copy_constructible(AllPrivate), ""); + static_assert(!__is_nothrow_copy_constructible(AllPrivate), ""); + static_assert(!__is_trivially_copy_constructible(AllPrivate), ""); + + static_assert(!__is_copy_constructible(AnIncompleteType[]), ""); + static_assert(!__is_nothrow_copy_constructible(AnIncompleteType[]), ""); + static_assert(!__is_trivially_copy_constructible(AnIncompleteType[]), ""); + + static_assert(!__is_copy_constructible(AnIncompleteType), ""); // expected-error{{incomplete type}} + static_assert(!__is_nothrow_copy_constructible(AnIncompleteType), ""); // expected-error{{incomplete type}} + static_assert(!__is_trivially_copy_constructible(AnIncompleteType), ""); // expected-error{{incomplete type}} + + static_assert(!__is_copy_constructible(BaseDeletedCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(BaseDeletedCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(BaseDeletedCopyCtor), ""); + + static_assert(!__is_copy_constructible(CopyCtorDeleted), ""); + static_assert(!__is_nothrow_copy_constructible(CopyCtorDeleted), ""); + static_assert(!__is_trivially_copy_constructible(CopyCtorDeleted), ""); + + static_assert(!__is_copy_constructible(HasMutableCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(HasMutableCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(HasMutableCopyCtor), ""); + + static_assert(!__is_copy_constructible(HasMove), ""); + static_assert(!__is_nothrow_copy_constructible(HasMove), ""); + static_assert(!__is_trivially_copy_constructible(HasMove), ""); + + static_assert(!__is_copy_constructible(HasMoveAssign), ""); + static_assert(!__is_nothrow_copy_constructible(HasMoveAssign), ""); + static_assert(!__is_trivially_copy_constructible(HasMoveAssign), ""); + + static_assert(!__is_copy_constructible(MemberDeletedCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(MemberDeletedCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(MemberDeletedCopyCtor), ""); + + static_assert(!__is_copy_constructible(VirtAr), ""); + static_assert(!__is_nothrow_copy_constructible(VirtAr), ""); + static_assert(!__is_trivially_copy_constructible(VirtAr), ""); + + static_assert(!__is_copy_constructible(VolatileCopyCtor), ""); + static_assert(!__is_nothrow_copy_constructible(VolatileCopyCtor), ""); + static_assert(!__is_trivially_copy_constructible(VolatileCopyCtor), ""); + + // Non-referencable types + static_assert(!__is_copy_constructible(void), ""); + static_assert(!__is_nothrow_copy_constructible(void), ""); + static_assert(!__is_trivially_copy_constructible(void), ""); + + static_assert(!__is_copy_constructible(void()), ""); + static_assert(!__is_nothrow_copy_constructible(void()), ""); + static_assert(!__is_trivially_copy_constructible(void()), ""); +} + // Instantiation of __is_trivially_constructible template<typename T, typename ...Args> struct is_trivially_constructible { Index: clang/test/SemaCXX/deprecated-builtins.cpp =================================================================== --- clang/test/SemaCXX/deprecated-builtins.cpp +++ clang/test/SemaCXX/deprecated-builtins.cpp @@ -7,11 +7,11 @@ a = __has_nothrow_assign(A); // expected-warning-re {{__has_nothrow_assign {{.*}} use __is_nothrow_assignable}} a = __has_nothrow_move_assign(A); // expected-warning-re {{__has_nothrow_move_assign {{.*}} use __is_nothrow_assignable}} - a = __has_nothrow_copy(A); // expected-warning-re {{__has_nothrow_copy {{.*}} use __is_nothrow_constructible}} + a = __has_nothrow_copy(A); // expected-warning-re {{__has_nothrow_copy {{.*}} use __is_nothrow_copy_constructible}} a = __has_nothrow_constructor(A); // expected-warning-re {{__has_nothrow_constructor {{.*}} use __is_nothrow_constructible}} a = __has_trivial_assign(A); // expected-warning-re {{__has_trivial_assign {{.*}} use __is_trivially_assignable}} a = __has_trivial_move_assign(A); // expected-warning-re {{__has_trivial_move_assign {{.*}} use __is_trivially_assignable}} - a = __has_trivial_copy(A); // expected-warning-re {{__has_trivial_copy {{.*}} use __is_trivially_copyable}} + a = __has_trivial_copy(A); // expected-warning-re {{__has_trivial_copy {{.*}} use __is_trivially_copy_constructible}} a = __has_trivial_constructor(A); // expected-warning-re {{__has_trivial_constructor {{.*}} use __is_trivially_constructible}} a = __has_trivial_move_constructor(A); // expected-warning-re {{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}} a = __has_trivial_destructor(A); // expected-warning-re {{__has_trivial_destructor {{.*}} use __is_trivially_destructible}} Index: clang/lib/Sema/SemaExprCXX.cpp =================================================================== --- clang/lib/Sema/SemaExprCXX.cpp +++ clang/lib/Sema/SemaExprCXX.cpp @@ -4848,6 +4848,9 @@ case UTT_IsNothrowDestructible: case UTT_IsTriviallyDestructible: case UTT_HasUniqueObjectRepresentations: + case UTT_IsCopyConstructible: + case UTT_IsTriviallyCopyConstructible: + case UTT_IsNothrowCopyConstructible: if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType()) return true; @@ -4891,6 +4894,12 @@ return false; } +static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc, + ArrayRef<TypeSourceInfo *> Args, + SourceLocation RParenLoc); +static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT, + QualType RhsT, SourceLocation KeyLoc); + static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, SourceLocation KeyLoc, QualType T) { assert(!T->isDependentType() && "Cannot evaluate traits of dependent type"); @@ -5305,6 +5314,27 @@ return C.hasUniqueObjectRepresentations(T); case UTT_IsTriviallyRelocatable: return T.isTriviallyRelocatableType(C); + case UTT_IsCopyConstructible: + case UTT_IsTriviallyCopyConstructible: + case UTT_IsNothrowCopyConstructible: { + if (T->isIncompleteArrayType()) + return false; + if (!T.isReferenceable()) + return false; + + QualType AssigneeType = T; + AssigneeType.addConst(); + AssigneeType = Self.BuiltinAddReference( + AssigneeType, UnaryTransformType::AddLvalueReference, KeyLoc); + llvm::SmallVector<TypeSourceInfo *, 2> Parameters = { + C.CreateTypeSourceInfo(T), C.CreateTypeSourceInfo(AssigneeType)}; + return evaluateTypeTrait(Self, + UTT == UTT_IsCopyConstructible ? TT_IsConstructible + : UTT == UTT_IsTriviallyCopyConstructible + ? TT_IsTriviallyConstructible + : TT_IsNothrowConstructible, + KeyLoc, Parameters, {}); + } case UTT_IsReferenceable: return T.isReferenceable(); } @@ -5443,6 +5473,8 @@ Replacement = BTT_IsNothrowAssignable; break; case UTT_HasNothrowCopy: + Replacement = UTT_IsNothrowCopyConstructible; + break; case UTT_HasNothrowConstructor: Replacement = TT_IsNothrowConstructible; break; @@ -5451,7 +5483,7 @@ Replacement = BTT_IsTriviallyAssignable; break; case UTT_HasTrivialCopy: - Replacement = UTT_IsTriviallyCopyable; + Replacement = UTT_IsTriviallyCopyConstructible; break; case UTT_HasTrivialDefaultConstructor: case UTT_HasTrivialMoveConstructor: Index: clang/lib/Parse/ParseExpr.cpp =================================================================== --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -1076,6 +1076,7 @@ REVERTIBLE_TYPE_TRAIT(__is_constructible); REVERTIBLE_TYPE_TRAIT(__is_convertible_to); REVERTIBLE_TYPE_TRAIT(__is_convertible); + REVERTIBLE_TYPE_TRAIT(__is_copy_constructible); REVERTIBLE_TYPE_TRAIT(__is_destructible); REVERTIBLE_TYPE_TRAIT(__is_empty); REVERTIBLE_TYPE_TRAIT(__is_enum); @@ -1093,6 +1094,7 @@ REVERTIBLE_TYPE_TRAIT(__is_member_pointer); REVERTIBLE_TYPE_TRAIT(__is_nothrow_assignable); REVERTIBLE_TYPE_TRAIT(__is_nothrow_constructible); + REVERTIBLE_TYPE_TRAIT(__is_nothrow_copy_constructible); REVERTIBLE_TYPE_TRAIT(__is_nothrow_destructible); REVERTIBLE_TYPE_TRAIT(__is_nullptr); REVERTIBLE_TYPE_TRAIT(__is_object); @@ -1112,6 +1114,7 @@ REVERTIBLE_TYPE_TRAIT(__is_trivial); REVERTIBLE_TYPE_TRAIT(__is_trivially_assignable); REVERTIBLE_TYPE_TRAIT(__is_trivially_constructible); + REVERTIBLE_TYPE_TRAIT(__is_trivially_copy_constructible); REVERTIBLE_TYPE_TRAIT(__is_trivially_copyable); REVERTIBLE_TYPE_TRAIT(__is_unbounded_array); REVERTIBLE_TYPE_TRAIT(__is_union); Index: clang/lib/Parse/ParseDeclCXX.cpp =================================================================== --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -1585,6 +1585,7 @@ tok::kw___is_compound, tok::kw___is_const, tok::kw___is_constructible, + tok::kw___is_copy_constructible, tok::kw___is_convertible, tok::kw___is_convertible_to, tok::kw___is_destructible, @@ -1604,6 +1605,7 @@ tok::kw___is_member_pointer, tok::kw___is_nothrow_assignable, tok::kw___is_nothrow_constructible, + tok::kw___is_nothrow_copy_constructible, tok::kw___is_nothrow_destructible, tok::kw___is_nullptr, tok::kw___is_object, @@ -1623,6 +1625,7 @@ tok::kw___is_trivial, tok::kw___is_trivially_assignable, tok::kw___is_trivially_constructible, + tok::kw___is_trivially_copy_constructible, tok::kw___is_trivially_copyable, tok::kw___is_unbounded_array, tok::kw___is_union, Index: clang/include/clang/Basic/TokenKinds.def =================================================================== --- clang/include/clang/Basic/TokenKinds.def +++ clang/include/clang/Basic/TokenKinds.def @@ -523,6 +523,9 @@ TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX) TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX) TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX) +TYPE_TRAIT_1(__is_copy_constructible, IsCopyConstructible, KEYCXX) +TYPE_TRAIT_1(__is_nothrow_copy_constructible, IsNothrowCopyConstructible, KEYCXX) +TYPE_TRAIT_1(__is_trivially_copy_constructible, IsTriviallyCopyConstructible, KEYCXX) TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX) // Embarcadero Expression Traits
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits