1 // RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s --check-prefixes=CHECK,ITANIUM
2 // RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple x86_64-pc-win32 2>&1 | FileCheck %s --check-prefixes=CHECK,MSABI
5 struct strong_ordering
{
7 constexpr operator int() const { return n
; }
8 static const strong_ordering less
, equal
, greater
;
10 constexpr strong_ordering
strong_ordering::less
= {-1};
11 constexpr strong_ordering
strong_ordering::equal
= {0};
12 constexpr strong_ordering
strong_ordering::greater
= {1};
17 std::strong_ordering
operator<=>(const Primary
&) const = default;
20 virtual struct Y
&operator=(Y
&&);
21 virtual struct Y
&operator=(const Y
&);
22 std::strong_ordering
operator<=>(const X
&) const = default;
24 // The vtable for Y should contain the following entries in order:
27 // - Y::operator=(const Y&) (implicit)
28 // - Y::operator=(Y&&) (implicit)
29 // - Y::operator==(const Y&) const (implicit)
31 // https://github.com/itanium-cxx-abi/cxx-abi/issues/83 for assignment operator
32 // https://github.com/itanium-cxx-abi/cxx-abi/issues/88 for equality comparison
33 // FIXME: What rule does MSVC use?
34 struct Y
: Primary
, X
{
35 virtual std::strong_ordering
operator<=>(const Y
&) const = default;
38 // ITANIUM: @_ZTV1Y = {{.*}}constant {{.*}} null, {{.*}} @_ZTI1Y, {{.*}} @_ZN7Primary1fEv, {{.*}} @_ZNK1YssERKS_, {{.*}} @_ZN1YaSERKS_, {{.*}} @_ZN1YaSEOS_, {{.*}} @_ZNK1YeqERKS_], {{.*}} -[[POINTERSIZE:4|8]]
39 // ITANIUM-SAME: @_ZTI1Y, {{.*}} @_ZThn[[POINTERSIZE]]_N1YaSERKS_
42 void operator<=>(int);
45 // ITANIUM: define {{.*}}@_ZN1AssEi(
46 // MSABI: define {{.*}}@"??__MA@@QEAAXH@Z"(
47 void A::operator<=>(int) {}
49 // ITANIUM: define {{.*}}@_Zssi1A(
50 // MSABI: define {{.*}}@"??__M@YAXHUA@@@Z"(
51 void operator<=>(int, A
) {}
53 int operator<=>(A
, A
);
55 // ITANIUM: define {{.*}}_Z1f1A(
56 // MSABI: define {{.*}}@"?f@@YAHUA@@@Z"(
58 // ITANIUM: %[[RET:.*]] = call {{.*}}_Zss1AS_(
59 // ITANIUM: ret i32 %[[RET]]
60 // MSABI: %[[RET:.*]] = call {{.*}}"??__M@YAHUA@@0@Z"(
61 // MSABI: ret i32 %[[RET]]
65 // CHECK-LABEL: define {{.*}}builtin_cmp
66 void builtin_cmp(int a
) {