Skip to content

NFC: make headers compatible with C++20 #67619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/Driver/Compilation.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Compilation {
Result(bool hadAbnormalExit, int exitCode,
fine_grained_dependencies::ModuleDepGraph depGraph)
: hadAbnormalExit(hadAbnormalExit), exitCode(exitCode),
depGraph(depGraph) {}
depGraph(std::move(depGraph)) {}

Result(const Result &) = delete;
Result &operator=(const Result &) = delete;
Expand Down
12 changes: 12 additions & 0 deletions include/swift/SIL/SILValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ struct ValueOwnershipKind {

explicit operator bool() const { return value != OwnershipKind::Any; }

#ifndef __cpp_impl_three_way_comparison
// C++20 (more precisely P1185) introduced more overload candidates for
// comparison operator calls. With that in place the following definitions are
// redundant and actually cause compilation errors because of ambiguity.
// P1630 explains the rationale behind introducing this backward
// incompatibility.
//
// References:
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r2.html
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1630r1.html

bool operator==(ValueOwnershipKind other) const {
return value == other.value;
}
Expand All @@ -280,6 +291,7 @@ struct ValueOwnershipKind {

bool operator==(innerty other) const { return value == other; }
bool operator!=(innerty other) const { return !(value == other); }
#endif

/// We merge by moving down the lattice.
ValueOwnershipKind merge(ValueOwnershipKind rhs) const {
Expand Down