Skip to content

Commit aa4ff7c

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 82453cf + 5bdc5cc commit aa4ff7c

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

lib/ClangImporter/ImportName.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,8 +1426,14 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
14261426
case clang::OverloadedOperatorKind::OO_Percent:
14271427
case clang::OverloadedOperatorKind::OO_Amp:
14281428
case clang::OverloadedOperatorKind::OO_Pipe:
1429+
case clang::OverloadedOperatorKind::OO_Less:
1430+
case clang::OverloadedOperatorKind::OO_Greater:
14291431
case clang::OverloadedOperatorKind::OO_LessLess:
14301432
case clang::OverloadedOperatorKind::OO_GreaterGreater:
1433+
case clang::OverloadedOperatorKind::OO_EqualEqual:
1434+
case clang::OverloadedOperatorKind::OO_ExclaimEqual:
1435+
case clang::OverloadedOperatorKind::OO_LessEqual:
1436+
case clang::OverloadedOperatorKind::OO_GreaterEqual:
14311437
case clang::OverloadedOperatorKind::OO_AmpAmp:
14321438
case clang::OverloadedOperatorKind::OO_PipePipe:
14331439
if (auto FD = dyn_cast<clang::FunctionDecl>(D)) {

test/Interop/Cxx/operators/Inputs/non-member-inline.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ inline IntBox operator>>(IntBox lhs, IntBox rhs) {
4141
return IntBox{.value = lhs.value >> rhs.value};
4242
}
4343

44+
inline bool operator<(IntBox lhs, IntBox rhs) { return lhs.value < rhs.value; }
45+
46+
inline bool operator>(IntBox lhs, IntBox rhs) { return lhs.value > rhs.value; }
47+
48+
inline bool operator==(IntBox lhs, IntBox rhs) {
49+
return lhs.value == rhs.value;
50+
}
51+
52+
inline bool operator!=(IntBox lhs, IntBox rhs) {
53+
return lhs.value != rhs.value;
54+
}
55+
56+
inline bool operator<=(IntBox lhs, IntBox rhs) {
57+
return lhs.value == rhs.value;
58+
}
59+
60+
inline bool operator>=(IntBox lhs, IntBox rhs) {
61+
return lhs.value != rhs.value;
62+
}
63+
4464
struct BoolBox {
4565
bool value;
4666
};

test/Interop/Cxx/operators/non-member-inline-module-interface.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
// CHECK-NEXT: func | (lhs: IntBox, rhs: IntBox) -> IntBox
1010
// CHECK-NEXT: func << (lhs: IntBox, rhs: IntBox) -> IntBox
1111
// CHECK-NEXT: func >> (lhs: IntBox, rhs: IntBox) -> IntBox
12+
// CHECK-NEXT: func < (lhs: IntBox, rhs: IntBox) -> Bool
13+
// CHECK-NEXT: func > (lhs: IntBox, rhs: IntBox) -> Bool
14+
// CHECK-NEXT: func == (lhs: IntBox, rhs: IntBox) -> Bool
15+
// CHECK-NEXT: func != (lhs: IntBox, rhs: IntBox) -> Bool
16+
// CHECK-NEXT: func <= (lhs: IntBox, rhs: IntBox) -> Bool
17+
// CHECK-NEXT: func >= (lhs: IntBox, rhs: IntBox) -> Bool
1218

1319
// CHECK: func && (lhs: BoolBox, rhs: BoolBox) -> BoolBox
1420
// CHECK-NEXT: func || (lhs: BoolBox, rhs: BoolBox) -> BoolBox

test/Interop/Cxx/operators/non-member-inline-typechecker.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ let resultAmp = lhs & rhs
1414
let resultPipe = lhs | rhs
1515
let resultLessLess = lhs << rhs
1616
let resultGreaterGreater = lhs >> rhs
17+
let resultLess = lhs < rhs
18+
let resultGreater = lhs > rhs
19+
let resultEqualEqual = lhs == rhs
20+
let resultExclaimEqual = lhs != rhs
21+
let resultLessEqual = lhs <= rhs
22+
let resultGreaterEqual = lhs >= rhs
1723

1824
var lhsBool = BoolBox(value: true)
1925
var rhsBool = BoolBox(value: false)

test/Interop/Cxx/operators/non-member-inline.swift

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ OperatorsTestSuite.test("slash (/)") {
4343
expectEqual(1, result.value)
4444
}
4545

46-
OperatorsTestSuite.test("percent") {
46+
OperatorsTestSuite.test("percent (%)") {
4747
let lhs = IntBox(value: 11)
4848
let rhs = IntBox(value: 2)
4949

@@ -52,7 +52,7 @@ OperatorsTestSuite.test("percent") {
5252
expectEqual(1, result.value)
5353
}
5454

55-
OperatorsTestSuite.test("amp") {
55+
OperatorsTestSuite.test("amp (&)") {
5656
let lhs = IntBox(value: 6)
5757
let rhs = IntBox(value: 5)
5858

@@ -61,7 +61,7 @@ OperatorsTestSuite.test("amp") {
6161
expectEqual(4, result.value)
6262
}
6363

64-
OperatorsTestSuite.test("pipe") {
64+
OperatorsTestSuite.test("pipe (|)") {
6565
let lhs = IntBox(value: 6)
6666
let rhs = IntBox(value: 5)
6767

@@ -70,6 +70,24 @@ OperatorsTestSuite.test("pipe") {
7070
expectEqual(7, result.value)
7171
}
7272

73+
OperatorsTestSuite.test("less (<)") {
74+
let lhs = IntBox(value: 5)
75+
let rhs = IntBox(value: 6)
76+
77+
let result = lhs < rhs
78+
79+
expectEqual(true, result)
80+
}
81+
82+
OperatorsTestSuite.test("greater (>)") {
83+
let lhs = IntBox(value: 5)
84+
let rhs = IntBox(value: 6)
85+
86+
let result = lhs > rhs
87+
88+
expectEqual(false, result)
89+
}
90+
7391
OperatorsTestSuite.test("less less (<<)") {
7492
let lhs = IntBox(value: 2)
7593
let rhs = IntBox(value: 4)
@@ -88,6 +106,42 @@ OperatorsTestSuite.test("greater greater (>>)") {
88106
expectEqual(2, result.value)
89107
}
90108

109+
OperatorsTestSuite.test("equal equal (==)") {
110+
let lhs = IntBox(value: 5)
111+
let rhs = IntBox(value: 5)
112+
113+
let result = lhs == rhs
114+
115+
expectEqual(true, result)
116+
}
117+
118+
OperatorsTestSuite.test("exclaim equal (!=)") {
119+
let lhs = IntBox(value: 5)
120+
let rhs = IntBox(value: 5)
121+
122+
let result = lhs != rhs
123+
124+
expectEqual(false, result)
125+
}
126+
127+
OperatorsTestSuite.test("less equal (<=)") {
128+
let lhs = IntBox(value: 5)
129+
let rhs = IntBox(value: 5)
130+
131+
let result = lhs <= rhs
132+
133+
expectEqual(true, result)
134+
}
135+
136+
OperatorsTestSuite.test("greater equal (>=)") {
137+
let lhs = IntBox(value: 6)
138+
let rhs = IntBox(value: 5)
139+
140+
let result = lhs >= rhs
141+
142+
expectEqual(true, result)
143+
}
144+
91145
OperatorsTestSuite.test("amp amp (&&)") {
92146
let lhs = BoolBox(value: true)
93147
let rhs = BoolBox(value: false)

0 commit comments

Comments
 (0)