Clang Project

clang_source_code/test/CodeGenCXX/cxx2a-three-way-comparison.cpp
1// RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s --check-prefix=ITANIUM
2// RUN: not %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple %ms_abi_triple 2>&1 | FileCheck %s --check-prefix=MSABI
3// RUN: not %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple %itanium_abi_triple -DBUILTIN 2>&1 | FileCheck %s --check-prefix=BUILTIN
4// MSABI: cannot mangle this three-way comparison operator yet
5
6struct A {
7  void operator<=>(int);
8};
9
10// ITANIUM: define {{.*}}@_ZN1AssEi(
11void A::operator<=>(int) {}
12
13// ITANIUM: define {{.*}}@_Zssi1A(
14void operator<=>(int, A) {}
15
16int operator<=>(A, A);
17
18// ITANIUM: define {{.*}}_Z1f1A(
19int f(A a) {
20  // ITANIUM: %[[RET:.*]] = call {{.*}}_Zss1AS_(
21  // ITANIUM: ret i32 %[[RET]]
22  return a <=> a;
23}
24
25#ifdef BUILTIN
26void builtin(int a) {
27  a <=> a; // BUILTIN: cannot compile this scalar expression yet
28}
29#endif
30