[clang] makes `__is_destructible` KEYALL instead of KEYMS
This makes it possible to be used in all modes, instead of just when `-fms-extensions` is enabled. Also moves the `-fms-extensions`-exclusive traits into their own file so we can check the others aren't dependent on this flag. This is information that the compiler already has, and should be exposed so that the library doesn't need to reimplement the exact same functionality. This was originally a part of D116280. Depends on D135177. Differential Revision: https://reviews.llvm.org/D135339
This commit is contained in:
parent
a089defa24
commit
14e64cb8d5
|
@ -1404,8 +1404,7 @@ The following type trait primitives are supported by Clang. Those traits marked
|
|||
* ``__is_convertible`` (C++, Embarcadero)
|
||||
* ``__is_convertible_to`` (Microsoft):
|
||||
Synonym for ``__is_convertible``.
|
||||
* ``__is_destructible`` (C++, MSVC 2013):
|
||||
Only available in ``-fms-extensions`` mode.
|
||||
* ``__is_destructible`` (C++, MSVC 2013)
|
||||
* ``__is_empty`` (C++, GNU, Microsoft, Embarcadero)
|
||||
* ``__is_enum`` (C++, GNU, Microsoft, Embarcadero)
|
||||
* ``__is_final`` (C++, GNU, Microsoft)
|
||||
|
@ -1427,7 +1426,6 @@ The following type trait primitives are supported by Clang. Those traits marked
|
|||
* ``__is_nothrow_assignable`` (C++, MSVC 2013)
|
||||
* ``__is_nothrow_constructible`` (C++, MSVC 2013)
|
||||
* ``__is_nothrow_destructible`` (C++, MSVC 2013)
|
||||
Only available in ``-fms-extensions`` mode.
|
||||
* ``__is_nullptr`` (C++, GNU, Microsoft, Embarcadero):
|
||||
Returns true for ``std::nullptr_t`` and false for everything else. The
|
||||
corresponding standard library feature is ``std::is_null_pointer``, but
|
||||
|
|
|
@ -466,9 +466,9 @@ TYPE_TRAIT_1(__is_interface_class, IsInterfaceClass, KEYMS)
|
|||
TYPE_TRAIT_1(__is_sealed, IsSealed, KEYMS)
|
||||
|
||||
// MSVC12.0 / VS2013 Type Traits
|
||||
TYPE_TRAIT_1(__is_destructible, IsDestructible, KEYMS)
|
||||
TYPE_TRAIT_1(__is_destructible, IsDestructible, KEYALL)
|
||||
TYPE_TRAIT_1(__is_trivially_destructible, IsTriviallyDestructible, KEYCXX)
|
||||
TYPE_TRAIT_1(__is_nothrow_destructible, IsNothrowDestructible, KEYMS)
|
||||
TYPE_TRAIT_1(__is_nothrow_destructible, IsNothrowDestructible, KEYALL)
|
||||
TYPE_TRAIT_2(__is_nothrow_assignable, IsNothrowAssignable, KEYCXX)
|
||||
TYPE_TRAIT_N(__is_constructible, IsConstructible, KEYCXX)
|
||||
TYPE_TRAIT_N(__is_nothrow_constructible, IsNothrowConstructible, KEYCXX)
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s -Wno-c++17-extensions
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s -Wno-c++17-extensions
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
|
||||
// RUN: %clang_cc1 -x c -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu11 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
using Int = int;
|
||||
|
||||
struct NonPOD { NonPOD(int); };
|
||||
enum Enum { EV };
|
||||
struct POD { Enum e; int i; float f; NonPOD* p; };
|
||||
struct Derives : POD {};
|
||||
using ClassType = Derives;
|
||||
|
||||
union Union { int i; float f; };
|
||||
|
||||
struct HasAnonymousUnion {
|
||||
union {
|
||||
int i;
|
||||
float f;
|
||||
};
|
||||
};
|
||||
|
||||
struct FinalClass final {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct PotentiallyFinal { };
|
||||
|
||||
template<typename T>
|
||||
struct PotentiallyFinal<T*> final { };
|
||||
|
||||
template<>
|
||||
struct PotentiallyFinal<int> final { };
|
||||
|
||||
struct SealedClass sealed {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct PotentiallySealed { };
|
||||
|
||||
template<typename T>
|
||||
struct PotentiallySealed<T*> sealed { };
|
||||
|
||||
template<>
|
||||
struct PotentiallySealed<int> sealed { };
|
||||
|
||||
void is_final() {
|
||||
static_assert(__is_final(SealedClass));
|
||||
static_assert(__is_final(PotentiallySealed<float*>));
|
||||
static_assert(__is_final(PotentiallySealed<int>));
|
||||
|
||||
static_assert(!__is_final(PotentiallyFinal<float>));
|
||||
static_assert(!__is_final(PotentiallySealed<float>));
|
||||
}
|
||||
|
||||
void is_sealed()
|
||||
{
|
||||
static_assert(__is_sealed(SealedClass));
|
||||
static_assert(__is_sealed(PotentiallySealed<float*>));
|
||||
static_assert(__is_sealed(PotentiallySealed<int>));
|
||||
static_assert(__is_sealed(FinalClass));
|
||||
static_assert(__is_sealed(PotentiallyFinal<float*>));
|
||||
static_assert(__is_sealed(PotentiallyFinal<int>));
|
||||
|
||||
static_assert(!__is_sealed(int));
|
||||
static_assert(!__is_sealed(Union));
|
||||
static_assert(!__is_sealed(Int));
|
||||
static_assert(!__is_sealed(Int[10]));
|
||||
static_assert(!__is_sealed(Union[10]));
|
||||
static_assert(!__is_sealed(Derives));
|
||||
static_assert(!__is_sealed(ClassType));
|
||||
static_assert(!__is_sealed(const void));
|
||||
static_assert(!__is_sealed(Int[]));
|
||||
static_assert(!__is_sealed(HasAnonymousUnion));
|
||||
static_assert(!__is_sealed(PotentiallyFinal<float>));
|
||||
static_assert(!__is_sealed(PotentiallySealed<float>));
|
||||
}
|
||||
#else
|
||||
struct s1 {};
|
||||
|
||||
void is_destructible()
|
||||
{
|
||||
(void)__is_destructible(int);
|
||||
(void)__is_destructible(struct s1);
|
||||
(void)__is_destructible(struct s2); // expected-error{{incomplete type 'struct s2' used in type trait expression}}
|
||||
// expected-note@-1{{}}
|
||||
}
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fblocks -Wno-deprecated-builtins %s
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fblocks -Wno-deprecated-builtins %s
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fblocks -Wno-deprecated-builtins %s
|
||||
|
||||
#define T(b) (b) ? 1 : -1
|
||||
#define F(b) (b) ? -1 : 1
|
||||
|
@ -414,23 +414,12 @@ struct PotentiallyFinal<T*> final { };
|
|||
template<>
|
||||
struct PotentiallyFinal<int> final { };
|
||||
|
||||
struct SealedClass sealed {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct PotentiallySealed { };
|
||||
|
||||
template<typename T>
|
||||
struct PotentiallySealed<T*> sealed { };
|
||||
|
||||
template<>
|
||||
struct PotentiallySealed<int> sealed { };
|
||||
|
||||
void is_final()
|
||||
{
|
||||
{ int arr[T(__is_final(SealedClass))]; }
|
||||
{ int arr[T(__is_final(PotentiallySealed<float*>))]; }
|
||||
{ int arr[T(__is_final(PotentiallySealed<int>))]; }
|
||||
{ int arr[T(__is_final(FinalClass))]; }
|
||||
{ int arr[T(__is_final(PotentiallyFinal<float*>))]; }
|
||||
{ int arr[T(__is_final(PotentiallyFinal<int>))]; }
|
||||
|
@ -445,32 +434,8 @@ void is_final()
|
|||
{ int arr[F(__is_final(cvoid))]; }
|
||||
{ int arr[F(__is_final(IntArNB))]; }
|
||||
{ int arr[F(__is_final(HasAnonymousUnion))]; }
|
||||
{ int arr[F(__is_final(PotentiallyFinal<float>))]; }
|
||||
{ int arr[F(__is_final(PotentiallySealed<float>))]; }
|
||||
}
|
||||
|
||||
void is_sealed()
|
||||
{
|
||||
{ int arr[T(__is_sealed(SealedClass))]; }
|
||||
{ int arr[T(__is_sealed(PotentiallySealed<float*>))]; }
|
||||
{ int arr[T(__is_sealed(PotentiallySealed<int>))]; }
|
||||
{ int arr[T(__is_sealed(FinalClass))]; }
|
||||
{ int arr[T(__is_sealed(PotentiallyFinal<float*>))]; }
|
||||
{ int arr[T(__is_sealed(PotentiallyFinal<int>))]; }
|
||||
|
||||
{ int arr[F(__is_sealed(int))]; }
|
||||
{ int arr[F(__is_sealed(Union))]; }
|
||||
{ int arr[F(__is_sealed(Int))]; }
|
||||
{ int arr[F(__is_sealed(IntAr))]; }
|
||||
{ int arr[F(__is_sealed(UnionAr))]; }
|
||||
{ int arr[F(__is_sealed(Derives))]; }
|
||||
{ int arr[F(__is_sealed(ClassType))]; }
|
||||
{ int arr[F(__is_sealed(cvoid))]; }
|
||||
{ int arr[F(__is_sealed(IntArNB))]; }
|
||||
{ int arr[F(__is_sealed(HasAnonymousUnion))]; }
|
||||
{ int arr[F(__is_sealed(PotentiallyFinal<float>))]; }
|
||||
{ int arr[F(__is_sealed(PotentiallySealed<float>))]; }
|
||||
}
|
||||
|
||||
typedef HasVirt Polymorph;
|
||||
struct InheritPolymorph : Polymorph {};
|
||||
|
|
Loading…
Reference in New Issue