Skip to content

Commit 86dadac

Browse files
authored
Merge pull request #36144 from egorzhdan/cxx-operators-tests-cleanup
C++ Interop: cleanup operator tests (NFC)
2 parents 5be886f + 6d5eba9 commit 86dadac

14 files changed

+113
-113
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "member-out-of-line.h"
22

3-
IntBox IntBox::operator+(IntBox rhs) const {
4-
return IntBox{.value = value + rhs.value};
3+
LoadableIntWrapper LoadableIntWrapper::operator+(LoadableIntWrapper rhs) const {
4+
return LoadableIntWrapper{.value = value + rhs.value};
55
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef TEST_INTEROP_CXX_OPERATORS_INPUTS_MEMBER_OUT_OF_LINE_H
22
#define TEST_INTEROP_CXX_OPERATORS_INPUTS_MEMBER_OUT_OF_LINE_H
33

4-
struct IntBox {
4+
struct LoadableIntWrapper {
55
int value;
6-
IntBox operator+(IntBox rhs) const;
6+
LoadableIntWrapper operator+(LoadableIntWrapper rhs) const;
77
};
88

99
#endif

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
#ifndef TEST_INTEROP_CXX_OPERATORS_INPUTS_NON_MEMBER_INLINE_H
22
#define TEST_INTEROP_CXX_OPERATORS_INPUTS_NON_MEMBER_INLINE_H
33

4-
struct IntBox {
4+
struct LoadableIntWrapper {
55
int value;
66
};
77

8-
inline IntBox operator+(IntBox lhs, IntBox rhs) {
9-
return IntBox{.value = lhs.value + rhs.value};
8+
inline LoadableIntWrapper operator+(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
9+
return LoadableIntWrapper{.value = lhs.value + rhs.value};
1010
}
1111

12-
inline IntBox operator-(IntBox lhs, IntBox rhs) {
13-
return IntBox{.value = lhs.value - rhs.value};
12+
inline LoadableIntWrapper operator-(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
13+
return LoadableIntWrapper{.value = lhs.value - rhs.value};
1414
}
1515

16-
inline IntBox operator*(IntBox lhs, IntBox rhs) {
17-
return IntBox{.value = lhs.value * rhs.value};
16+
inline LoadableIntWrapper operator*(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
17+
return LoadableIntWrapper{.value = lhs.value * rhs.value};
1818
}
1919

20-
inline IntBox operator/(IntBox lhs, IntBox rhs) {
21-
return IntBox{.value = lhs.value / rhs.value};
20+
inline LoadableIntWrapper operator/(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
21+
return LoadableIntWrapper{.value = lhs.value / rhs.value};
2222
}
2323

24-
inline IntBox operator%(IntBox lhs, IntBox rhs) {
25-
return IntBox{.value = lhs.value % rhs.value};
24+
inline LoadableIntWrapper operator%(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
25+
return LoadableIntWrapper{.value = lhs.value % rhs.value};
2626
}
2727

28-
inline IntBox operator&(IntBox lhs, IntBox rhs) {
29-
return IntBox{.value = lhs.value & rhs.value};
28+
inline LoadableIntWrapper operator&(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
29+
return LoadableIntWrapper{.value = lhs.value & rhs.value};
3030
}
3131

32-
inline IntBox operator|(IntBox lhs, IntBox rhs) {
33-
return IntBox{.value = lhs.value | rhs.value};
32+
inline LoadableIntWrapper operator|(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
33+
return LoadableIntWrapper{.value = lhs.value | rhs.value};
3434
}
3535

36-
inline IntBox operator<<(IntBox lhs, IntBox rhs) {
37-
return IntBox{.value = lhs.value << rhs.value};
36+
inline LoadableIntWrapper operator<<(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
37+
return LoadableIntWrapper{.value = lhs.value << rhs.value};
3838
}
3939

40-
inline IntBox operator>>(IntBox lhs, IntBox rhs) {
41-
return IntBox{.value = lhs.value >> rhs.value};
40+
inline LoadableIntWrapper operator>>(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
41+
return LoadableIntWrapper{.value = lhs.value >> rhs.value};
4242
}
4343

44-
inline bool operator<(IntBox lhs, IntBox rhs) { return lhs.value < rhs.value; }
44+
inline bool operator<(LoadableIntWrapper lhs, LoadableIntWrapper rhs) { return lhs.value < rhs.value; }
4545

46-
inline bool operator>(IntBox lhs, IntBox rhs) { return lhs.value > rhs.value; }
46+
inline bool operator>(LoadableIntWrapper lhs, LoadableIntWrapper rhs) { return lhs.value > rhs.value; }
4747

48-
inline bool operator==(IntBox lhs, IntBox rhs) {
48+
inline bool operator==(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
4949
return lhs.value == rhs.value;
5050
}
5151

52-
inline bool operator!=(IntBox lhs, IntBox rhs) {
52+
inline bool operator!=(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
5353
return lhs.value != rhs.value;
5454
}
5555

56-
inline bool operator<=(IntBox lhs, IntBox rhs) {
56+
inline bool operator<=(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
5757
return lhs.value == rhs.value;
5858
}
5959

60-
inline bool operator>=(IntBox lhs, IntBox rhs) {
60+
inline bool operator>=(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
6161
return lhs.value != rhs.value;
6262
}
6363

64-
struct BoolBox {
64+
struct LoadableBoolWrapper {
6565
bool value;
6666
};
6767

68-
inline BoolBox operator&&(BoolBox lhs, BoolBox rhs) {
69-
return BoolBox{.value = lhs.value && rhs.value};
68+
inline LoadableBoolWrapper operator&&(LoadableBoolWrapper lhs, LoadableBoolWrapper rhs) {
69+
return LoadableBoolWrapper{.value = lhs.value && rhs.value};
7070
}
7171

72-
inline BoolBox operator||(BoolBox lhs, BoolBox rhs) {
73-
return BoolBox{.value = lhs.value || rhs.value};
72+
inline LoadableBoolWrapper operator||(LoadableBoolWrapper lhs, LoadableBoolWrapper rhs) {
73+
return LoadableBoolWrapper{.value = lhs.value || rhs.value};
7474
}
7575

7676
// Make sure that we don't crash on templated operators
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "non-member-out-of-line.h"
22

3-
IntBox operator+(IntBox lhs, IntBox rhs) {
4-
return IntBox{.value = lhs.value + rhs.value};
3+
LoadableIntWrapper operator+(LoadableIntWrapper lhs, LoadableIntWrapper rhs) {
4+
return LoadableIntWrapper{.value = lhs.value + rhs.value};
55
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef TEST_INTEROP_CXX_OPERATORS_INPUTS_NON_MEMBER_OUT_OF_LINE_H
22
#define TEST_INTEROP_CXX_OPERATORS_INPUTS_NON_MEMBER_OUT_OF_LINE_H
33

4-
struct IntBox {
4+
struct LoadableIntWrapper {
55
int value;
66
};
77

8-
IntBox operator+(IntBox lhs, IntBox rhs);
8+
LoadableIntWrapper operator+(LoadableIntWrapper lhs, LoadableIntWrapper rhs);
99

1010
#endif

test/Interop/Cxx/operators/member-out-of-line-irgen.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import MemberOutOfLine
77

8-
public func add(_ lhs: inout IntBox, _ rhs: IntBox) -> IntBox { lhs + rhs }
8+
public func add(_ lhs: inout LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> LoadableIntWrapper { lhs + rhs }
99

10-
// CHECK: call {{i32|i64}} [[NAME:@_ZNK6IntBoxplES_]](%struct.IntBox* %{{[0-9]+}}, {{i32|\[1 x i32\]|i64|%struct.IntBox\* byval\(.*\) align 4}} %{{[0-9]+}})
11-
// CHECK: declare {{(dso_local )?}}{{i32|i64}} [[NAME]](%struct.IntBox* nonnull dereferenceable(4), {{i32|\[1 x i32\]|i64|%struct.IntBox\* byval\(%struct.IntBox\) align 4}})
10+
// CHECK: call {{i32|i64}} [[NAME:@_ZNK18LoadableIntWrapperplES_]](%struct.LoadableIntWrapper* %{{[0-9]+}}, {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* byval\(.*\) align 4}} %{{[0-9]+}})
11+
// CHECK: declare {{(dso_local )?}}{{i32|i64}} [[NAME]](%struct.LoadableIntWrapper* nonnull dereferenceable(4), {{i32|\[1 x i32\]|i64|%struct.LoadableIntWrapper\* byval\(%struct.LoadableIntWrapper\) align 4}})

test/Interop/Cxx/operators/member-out-of-line-silgen.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
import MemberOutOfLine
77

8-
public func add(_ lhs: inout IntBox, _ rhs: IntBox) -> IntBox { lhs + rhs }
8+
public func add(_ lhs: inout LoadableIntWrapper, _ rhs: LoadableIntWrapper) -> LoadableIntWrapper { lhs + rhs }
99

10-
// CHECK: bb0([[LHS:%.*]] : $*IntBox, [[RHS:%.*]] : $IntBox):
11-
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [static] [[LHS]] : $*IntBox
12-
// CHECK: [[FUNC:%.*]] = function_ref [[NAME:@_ZNK6IntBoxplES_]] : $@convention(c) (@inout IntBox, IntBox) -> IntBox
13-
// CHECK: apply [[FUNC]]([[ACCESS]], [[RHS]]) : $@convention(c) (@inout IntBox, IntBox) -> IntBox
14-
// CHECK: end_access [[ACCESS]] : $*IntBox
10+
// CHECK: bb0([[LHS:%.*]] : $*LoadableIntWrapper, [[RHS:%.*]] : $LoadableIntWrapper):
11+
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [static] [[LHS]] : $*LoadableIntWrapper
12+
// CHECK: [[FUNC:%.*]] = function_ref [[NAME:@_ZNK18LoadableIntWrapperplES_]] : $@convention(c) (@inout LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper
13+
// CHECK: apply [[FUNC]]([[ACCESS]], [[RHS]]) : $@convention(c) (@inout LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper
14+
// CHECK: end_access [[ACCESS]] : $*LoadableIntWrapper
1515

16-
// CHECK: sil [clang IntBox."+"] [[NAME]] : $@convention(c) (@inout IntBox, IntBox) -> IntBox
16+
// CHECK: sil [clang LoadableIntWrapper."+"] [[NAME]] : $@convention(c) (@inout LoadableIntWrapper, LoadableIntWrapper) -> LoadableIntWrapper

test/Interop/Cxx/operators/member-out-of-line.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import StdlibUnittest
1515
var OperatorsTestSuite = TestSuite("Operators")
1616

1717
OperatorsTestSuite.test("plus") {
18-
var lhs = IntBox(value: 42)
19-
let rhs = IntBox(value: 23)
18+
var lhs = LoadableIntWrapper(value: 42)
19+
let rhs = LoadableIntWrapper(value: 23)
2020

2121
let result = lhs + rhs
2222

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// RUN: %target-swift-ide-test -print-module -module-to-print=NonMemberInline -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s
22

3-
// CHECK: func + (lhs: IntBox, rhs: IntBox) -> IntBox
4-
// CHECK-NEXT: func - (lhs: IntBox, rhs: IntBox) -> IntBox
5-
// CHECK-NEXT: func * (lhs: IntBox, rhs: IntBox) -> IntBox
6-
// CHECK-NEXT: func / (lhs: IntBox, rhs: IntBox) -> IntBox
7-
// CHECK-NEXT: func % (lhs: IntBox, rhs: IntBox) -> IntBox
8-
// CHECK-NEXT: func & (lhs: IntBox, rhs: IntBox) -> IntBox
9-
// CHECK-NEXT: func | (lhs: IntBox, rhs: IntBox) -> IntBox
10-
// CHECK-NEXT: func << (lhs: IntBox, rhs: IntBox) -> IntBox
11-
// 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
3+
// CHECK: func + (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
4+
// CHECK-NEXT: func - (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
5+
// CHECK-NEXT: func * (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
6+
// CHECK-NEXT: func / (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
7+
// CHECK-NEXT: func % (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
8+
// CHECK-NEXT: func & (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
9+
// CHECK-NEXT: func | (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
10+
// CHECK-NEXT: func << (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
11+
// CHECK-NEXT: func >> (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
12+
// CHECK-NEXT: func < (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> Bool
13+
// CHECK-NEXT: func > (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> Bool
14+
// CHECK-NEXT: func == (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> Bool
15+
// CHECK-NEXT: func != (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> Bool
16+
// CHECK-NEXT: func <= (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> Bool
17+
// CHECK-NEXT: func >= (lhs: LoadableIntWrapper, rhs: LoadableIntWrapper) -> Bool
1818

19-
// CHECK: func && (lhs: BoolBox, rhs: BoolBox) -> BoolBox
20-
// CHECK-NEXT: func || (lhs: BoolBox, rhs: BoolBox) -> BoolBox
19+
// CHECK: func && (lhs: LoadableBoolWrapper, rhs: LoadableBoolWrapper) -> LoadableBoolWrapper
20+
// CHECK-NEXT: func || (lhs: LoadableBoolWrapper, rhs: LoadableBoolWrapper) -> LoadableBoolWrapper

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import NonMemberInline
44

5-
var lhs = IntBox(value: 42)
6-
var rhs = IntBox(value: 23)
5+
var lhs = LoadableIntWrapper(value: 42)
6+
var rhs = LoadableIntWrapper(value: 23)
77

88
let resultPlus = lhs + rhs
99
let resultMinus = lhs - rhs
@@ -21,8 +21,8 @@ let resultExclaimEqual = lhs != rhs
2121
let resultLessEqual = lhs <= rhs
2222
let resultGreaterEqual = lhs >= rhs
2323

24-
var lhsBool = BoolBox(value: true)
25-
var rhsBool = BoolBox(value: false)
24+
var lhsBool = LoadableBoolWrapper(value: true)
25+
var rhsBool = LoadableBoolWrapper(value: false)
2626

2727
let resultAmpAmp = lhsBool && rhsBool
2828
let resultPipePipe = lhsBool && rhsBool

0 commit comments

Comments
 (0)