@@ -86,6 +86,35 @@ TEST(TestSwiftDemangleAsyncNames, BasicAsync) {
86
86
CheckFuncletNumbersAreARange (generic_funclets);
87
87
}
88
88
89
+ // The funclets below are created from this program:
90
+ // swiftc -g -Onone test.swift -o - -emit-ir -module-name a \
91
+ // | grep "define.*sayHello"
92
+ // func work() async {}
93
+ // func sayHello() async {
94
+ // let closure: (Any) async -> () = { _ in
95
+ // print("hello")
96
+ // await work()
97
+ // print("hello")
98
+ //
99
+ // let inner_closure: (Any) async -> () = { _ in
100
+ // print("hello")
101
+ // await work()
102
+ // print("hello")
103
+ // }
104
+ // await inner_closure(10)
105
+ // print("hello")
106
+ //
107
+ // let inner_closure2: (Any) async -> () = { _ in
108
+ // print("hello")
109
+ // await work()
110
+ // print("hello")
111
+ // }
112
+ //
113
+ // await inner_closure2(10)
114
+ // print("hello")
115
+ // }
116
+ // await closure(10)
117
+ // }
89
118
TEST (TestSwiftDemangleAsyncNames, ClosureAsync) {
90
119
// These are all async closures
91
120
SmallVector<StringRef> nested1_funclets = {
@@ -116,34 +145,30 @@ TEST(TestSwiftDemangleAsyncNames, ClosureAsync) {
116
145
" $s1a18myNonAsyncFunctionyyFyyYacfU_SiypYacfU_SSypYacfU0_TQ1_" ,
117
146
" $s1a18myNonAsyncFunctionyyFyyYacfU_SiypYacfU_SSypYacfU0_TY2_" };
118
147
119
- for (StringRef async_name : llvm::concat<StringRef>(
120
- nested1_funclets, nested2_funclets1, nested2_funclets2,
121
- nested2_funclets_top_not_async)) {
122
- EXPECT_TRUE (IsSwiftMangledName (async_name)) << async_name;
123
- EXPECT_TRUE (IsAnySwiftAsyncFunctionSymbol (async_name)) << async_name;
124
- }
148
+ SmallVector<ArrayRef<StringRef>, 0 > funclet_groups = {
149
+ nested1_funclets,
150
+ nested2_funclets1,
151
+ nested2_funclets2,
152
+ nested2_funclets_top_not_async,
153
+ };
154
+
155
+ for (ArrayRef<StringRef> funclet_group : funclet_groups)
156
+ for (StringRef async_name : funclet_group) {
157
+ EXPECT_TRUE (IsSwiftMangledName (async_name)) << async_name;
158
+ EXPECT_TRUE (IsAnySwiftAsyncFunctionSymbol (async_name)) << async_name;
159
+ }
160
+
161
+ for (ArrayRef<StringRef> funclet_group : funclet_groups)
162
+ CheckGroupOfFuncletsFromSameFunction (funclet_group);
163
+
164
+ for (ArrayRef<StringRef> funclet_group1 : funclet_groups)
165
+ for (ArrayRef<StringRef> funclet_group2 : funclet_groups)
166
+ if (funclet_group1.data () != funclet_group2.data ())
167
+ CheckGroupOfFuncletsFromDifferentFunctions (funclet_group1,
168
+ funclet_group2);
125
169
126
- CheckGroupOfFuncletsFromSameFunction (nested1_funclets);
127
- CheckGroupOfFuncletsFromSameFunction (nested2_funclets1);
128
- CheckGroupOfFuncletsFromSameFunction (nested2_funclets2);
129
- CheckGroupOfFuncletsFromSameFunction (nested2_funclets_top_not_async);
130
-
131
- CheckGroupOfFuncletsFromDifferentFunctions (nested1_funclets,
132
- nested2_funclets1);
133
- CheckGroupOfFuncletsFromDifferentFunctions (nested1_funclets,
134
- nested2_funclets2);
135
- CheckGroupOfFuncletsFromDifferentFunctions (nested1_funclets,
136
- nested2_funclets_top_not_async);
137
- CheckGroupOfFuncletsFromDifferentFunctions (nested2_funclets1,
138
- nested2_funclets2);
139
- CheckGroupOfFuncletsFromDifferentFunctions (nested2_funclets1,
140
- nested2_funclets_top_not_async);
141
- CheckGroupOfFuncletsFromDifferentFunctions (nested2_funclets2,
142
- nested2_funclets_top_not_async);
143
- CheckFuncletNumbersAreARange (nested1_funclets);
144
- CheckFuncletNumbersAreARange (nested2_funclets1);
145
- CheckFuncletNumbersAreARange (nested2_funclets2);
146
- CheckFuncletNumbersAreARange (nested2_funclets_top_not_async);
170
+ for (ArrayRef<StringRef> funclet_group : funclet_groups)
171
+ CheckFuncletNumbersAreARange (funclet_group);
147
172
}
148
173
149
174
TEST (TestSwiftDemangleAsyncNames, StaticAsync) {
0 commit comments