Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGenCXX/cxx2a-compare.cpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

104 lines
3.6 KiB
C++

// RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple %itanium_abi_triple | \
// RUN: FileCheck %s \
// RUN: '-DSO="class.std::__1::strong_ordering"' \
// RUN: '-DPO="class.std::__1::partial_ordering"' \
// RUN: -DEQ=0 -DLT=-1 -DGT=1 -DUNORD=-127 -DNE=1
#include "Inputs/std-compare.h"
// Ensure we don't emit definitions for the global variables
// since the builtins shouldn't ODR use them.
// CHECK-NOT: constant %[[SO]]
// CHECK-NOT: constant %[[PO]]
// CHECK-LABEL: @_Z11test_signedii
auto test_signed(int x, int y) {
// CHECK: %[[DEST:retval|agg.result]]
// CHECK: %cmp.lt = icmp slt i32 %{{.+}}, %{{.+}}
// CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
// CHECK: %cmp.eq = icmp eq i32 %{{.+}}, %{{.+}}
// CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
// CHECK: %__value_ = getelementptr inbounds nuw %[[SO]], ptr %[[DEST]]
// CHECK: store i8 %sel.eq, ptr %__value_, align 1
// CHECK: ret
return x <=> y;
}
// CHECK-LABEL: @_Z13test_unsignedjj
auto test_unsigned(unsigned x, unsigned y) {
// CHECK: %[[DEST:retval|agg.result]]
// CHECK: %cmp.lt = icmp ult i32 %{{.+}}, %{{.+}}
// CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
// CHECK: %cmp.eq = icmp eq i32 %{{.+}}, %{{.+}}
// CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
// CHECK: %__value_ = getelementptr inbounds nuw %[[SO]], ptr %[[DEST]]
// CHECK: store i8 %sel.eq, ptr %__value_
// CHECK: ret
return x <=> y;
}
// CHECK-LABEL: @_Z10float_testdd
auto float_test(double x, double y) {
// CHECK: %[[DEST:retval|agg.result]]
// CHECK: %cmp.eq = fcmp oeq double %{{.+}}, %{{.+}}
// CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 [[UNORD]]
// CHECK: %cmp.gt = fcmp ogt double %{{.+}}, %{{.+}}
// CHECK: %sel.gt = select i1 %cmp.gt, i8 [[GT]], i8 %sel.eq
// CHECK: %cmp.lt = fcmp olt double %{{.+}}, %{{.+}}
// CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 %sel.gt
// CHECK: %__value_ = getelementptr inbounds nuw %[[PO]], ptr %[[DEST]]
// CHECK: store i8 %sel.lt, ptr %__value_
// CHECK: ret
return x <=> y;
}
// CHECK-LABEL: @_Z8ptr_testPiS_
auto ptr_test(int *x, int *y) {
// CHECK: %[[DEST:retval|agg.result]]
// CHECK: %cmp.lt = icmp ult ptr %{{.+}}, %{{.+}}
// CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
// CHECK: %cmp.eq = icmp eq ptr %{{.+}}, %{{.+}}
// CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
// CHECK: %__value_ = getelementptr inbounds nuw %[[SO]], ptr %[[DEST]]
// CHECK: store i8 %sel.eq, ptr %__value_, align 1
// CHECK: ret
return x <=> y;
}
// CHECK-LABEL: @_Z13test_constantv
auto test_constant() {
// CHECK: %[[DEST:retval|agg.result]]
// CHECK-NOT: icmp
// CHECK: %__value_ = getelementptr inbounds nuw %[[SO]], ptr %[[DEST]]
// CHECK-NEXT: store i8 -1, ptr %__value_
// CHECK: ret
const int x = 42;
const int y = 101;
return x <=> y;
}
// CHECK-LABEL: @_Z18unscoped_enum_testijxy
void unscoped_enum_test(int i, unsigned u, long long l, unsigned long long ul) {
enum EnumA : int { A };
enum EnumB : unsigned { B };
// CHECK: %[[I:.*]] = load {{.*}} %i.addr
// CHECK: icmp slt i32 {{.*}} %[[I]]
(void)(A <=> i);
// CHECK: %[[U:.*]] = load {{.*}} %u.addr
// CHECK: icmp ult i32 {{.*}} %[[U]]
(void)(A <=> u);
// CHECK: %[[L:.*]] = load {{.*}} %l.addr
// CHECK: icmp slt i64 {{.*}} %[[L]]
(void)(A <=> l);
// CHECK: %[[U2:.*]] = load {{.*}} %u.addr
// CHECK: icmp ult i32 {{.*}} %[[U2]]
(void)(B <=> u);
// CHECK: %[[UL:.*]] = load {{.*}} %ul.addr
// CHECK: icmp ult i64 {{.*}} %[[UL]]
(void)(B <=> ul);
}