another try at fixing Mac's spaceship build
MODIFY
ir/state.cpp
ir/state.cpp
@@ -75,11 +75,6 @@ State::ValueAnalysis::FnCallRanges::overlaps(const FnCallRanges &other) const {
return true;
}
-bool State::VarArgsEntry::operator<(const VarArgsEntry &rhs) const {
- return tie(alive, next_arg, num_args, is_va_start, active) <
- tie(rhs.alive, rhs.next_arg, rhs.num_args, rhs.is_va_start, rhs.active);
-}
-
State::VarArgsData
State::VarArgsData::mkIf(const expr &cond, const VarArgsData &then,
const VarArgsData &els) {

MODIFY
ir/state.h
ir/state.h
@@ -68,16 +68,14 @@ private:
num_args(std::move(num_args)), is_va_start(std::move(is_va_start)),
active(std::move(active)) {}
- // FIXME: upgrade with C++20
- bool operator<(const VarArgsEntry &rhs) const;
+ auto operator<=>(const VarArgsEntry &rhs) const = default;
};
struct VarArgsData {
std::map<smt::expr, VarArgsEntry> data;
static VarArgsData mkIf(const smt::expr &cond, const VarArgsData &then,
const VarArgsData &els);
- // FIXME: upgrade with C++20
- bool operator<(const VarArgsData &rhs) const { return data < rhs.data; }
+ auto operator<=>(const VarArgsData &rhs) const = default;
};
struct BasicBlockInfo {

MODIFY
smt/exprs.cpp
smt/exprs.cpp
#include "smt/exprs.h"
#include "smt/smt.h"
#include "util/compiler.h"
+#include "util/spaceship.h"
#include <vector>
using namespace std;

MODIFY
util/spaceship.h
util/spaceship.h
@@ -25,6 +25,26 @@ std::weak_ordering operator<=>(const std::vector<T> &lhs,
return std::weak_ordering::equivalent;
}
+template <typename K, typename V>
+std::weak_ordering operator<=>(const std::map<K,V> &lhs,
+ const std::map<K,V> &rhs) {
+ auto sz = lhs.size() <=> rhs.size();
+ if (std::is_neq(sz))
+ return sz;
+
+ auto I = rhs.begin();
+ for (const auto &[k,v] : lhs) {
+ if (auto cmp = k <=> I->first;
+ std::is_neq(cmp))
+ return cmp;
+ if (auto cmp = v <=> I->second;
+ std::is_neq(cmp))
+ return cmp;
+ ++I;
+ }
+ return std::weak_ordering::equivalent;
+}
+
}
#endif

another try at fixing Mac's spaceship build