Skip to content

Commit 9d53f54

Browse files
authored
Merge pull request #67619 from redsun82/c++20-compatibility
NFC: make headers compatible with C++20
2 parents 72dd727 + 5b75522 commit 9d53f54

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

include/swift/Driver/Compilation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Compilation {
9292
Result(bool hadAbnormalExit, int exitCode,
9393
fine_grained_dependencies::ModuleDepGraph depGraph)
9494
: hadAbnormalExit(hadAbnormalExit), exitCode(exitCode),
95-
depGraph(depGraph) {}
95+
depGraph(std::move(depGraph)) {}
9696

9797
Result(const Result &) = delete;
9898
Result &operator=(const Result &) = delete;

include/swift/SIL/SILValue.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,17 @@ struct ValueOwnershipKind {
271271

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

274+
#ifndef __cpp_impl_three_way_comparison
275+
// C++20 (more precisely P1185) introduced more overload candidates for
276+
// comparison operator calls. With that in place the following definitions are
277+
// redundant and actually cause compilation errors because of ambiguity.
278+
// P1630 explains the rationale behind introducing this backward
279+
// incompatibility.
280+
//
281+
// References:
282+
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r2.html
283+
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1630r1.html
284+
274285
bool operator==(ValueOwnershipKind other) const {
275286
return value == other.value;
276287
}
@@ -280,6 +291,7 @@ struct ValueOwnershipKind {
280291

281292
bool operator==(innerty other) const { return value == other; }
282293
bool operator!=(innerty other) const { return !(value == other); }
294+
#endif
283295

284296
/// We merge by moving down the lattice.
285297
ValueOwnershipKind merge(ValueOwnershipKind rhs) const {

0 commit comments

Comments
 (0)