@@ -169,6 +169,45 @@ enum class SILFunctionTypeRepresentation : uint8_t {
169
169
Closure,
170
170
};
171
171
172
+ // / Returns true if the function with this convention doesn't carry a context.
173
+ constexpr bool
174
+ isThinRepresentation (FunctionTypeRepresentation rep) {
175
+ switch (rep) {
176
+ case FunctionTypeRepresentation::Swift:
177
+ case FunctionTypeRepresentation::Block:
178
+ return false ;
179
+ case FunctionTypeRepresentation::Thin:
180
+ case FunctionTypeRepresentation::CFunctionPointer:
181
+ return true ;
182
+ }
183
+ llvm_unreachable (" Unhandled FunctionTypeRepresentation in switch." );
184
+ }
185
+
186
+ // / Returns true if the function with this convention doesn't carry a context.
187
+ constexpr bool
188
+ isThinRepresentation (SILFunctionTypeRepresentation rep) {
189
+ switch (rep) {
190
+ case SILFunctionTypeRepresentation::Thick:
191
+ case SILFunctionTypeRepresentation::Block:
192
+ return false ;
193
+ case SILFunctionTypeRepresentation::Thin:
194
+ case SILFunctionTypeRepresentation::Method:
195
+ case SILFunctionTypeRepresentation::ObjCMethod:
196
+ case SILFunctionTypeRepresentation::WitnessMethod:
197
+ case SILFunctionTypeRepresentation::CFunctionPointer:
198
+ case SILFunctionTypeRepresentation::Closure:
199
+ return true ;
200
+ }
201
+ llvm_unreachable (" Unhandled SILFunctionTypeRepresentation in switch." );
202
+ }
203
+
204
+ // / Returns true if the function with this convention carries a context.
205
+ template <typename Repr>
206
+ constexpr bool
207
+ isThickRepresentation (Repr repr) {
208
+ return !isThinRepresentation (repr);
209
+ }
210
+
172
211
constexpr SILFunctionTypeRepresentation
173
212
convertRepresentation (FunctionTypeRepresentation rep) {
174
213
switch (rep) {
@@ -350,19 +389,7 @@ class ASTExtInfoBuilder {
350
389
351
390
// / True if the function representation carries context.
352
391
constexpr bool hasContext () const {
353
- switch (getSILRepresentation ()) {
354
- case SILFunctionTypeRepresentation::Thick:
355
- case SILFunctionTypeRepresentation::Block:
356
- return true ;
357
- case SILFunctionTypeRepresentation::Thin:
358
- case SILFunctionTypeRepresentation::Method:
359
- case SILFunctionTypeRepresentation::ObjCMethod:
360
- case SILFunctionTypeRepresentation::WitnessMethod:
361
- case SILFunctionTypeRepresentation::CFunctionPointer:
362
- case SILFunctionTypeRepresentation::Closure:
363
- return false ;
364
- }
365
- llvm_unreachable (" Unhandled SILFunctionTypeRepresentation in switch." );
392
+ return isThickRepresentation (getSILRepresentation ());
366
393
}
367
394
368
395
// Note that we don't have setters. That is by design, use
0 commit comments