@@ -75,12 +75,8 @@ getBridgingFn(Optional<SILDeclRef> &cacheSlot,
75
75
SILGenModule &SGM,
76
76
Identifier moduleName,
77
77
StringRef functionName,
78
- Optional<std::initializer_list<Type>> inputTypes,
79
- Optional<Type> outputType) {
80
- // FIXME: the optionality of outputType and the presence of trustInputTypes
81
- // are hacks for cases where coming up with those types is complicated, i.e.,
82
- // when dealing with generic bridging functions.
83
-
78
+ std::initializer_list<Type> inputTypes,
79
+ Type outputType) {
84
80
if (!cacheSlot) {
85
81
ASTContext &ctx = SGM.M .getASTContext ();
86
82
ModuleDecl *mod = ctx.getLoadedModule (moduleName);
@@ -122,21 +118,18 @@ getBridgingFn(Optional<SILDeclRef> &cacheSlot,
122
118
return SGM.Types .getLoweredType (ty, TypeExpansionContext::minimal ());
123
119
};
124
120
125
- if (inputTypes) {
126
- if (fnConv.hasIndirectSILResults ()
127
- || funcTy->getNumParameters () != inputTypes->size ()
128
- || !std::equal (
129
- fnConv.getParameterSILTypes ().begin (),
130
- fnConv.getParameterSILTypes ().end (),
131
- makeTransformIterator (inputTypes->begin (), toSILType))) {
132
- SGM.diagnose (fd->getLoc (), diag::bridging_function_not_correct_type,
133
- moduleName.str (), functionName);
134
- llvm::report_fatal_error (" unable to set up the ObjC bridge!" );
135
- }
121
+ if (fnConv.hasIndirectSILResults ()
122
+ || funcTy->getNumParameters () != inputTypes.size ()
123
+ || !std::equal (
124
+ fnConv.getParameterSILTypes ().begin (),
125
+ fnConv.getParameterSILTypes ().end (),
126
+ makeTransformIterator (inputTypes.begin (), toSILType))) {
127
+ SGM.diagnose (fd->getLoc (), diag::bridging_function_not_correct_type,
128
+ moduleName.str (), functionName);
129
+ llvm::report_fatal_error (" unable to set up the ObjC bridge!" );
136
130
}
137
131
138
- if (outputType
139
- && fnConv.getSingleSILResultType () != toSILType (*outputType)) {
132
+ if (fnConv.getSingleSILResultType () != toSILType (outputType)) {
140
133
SGM.diagnose (fd->getLoc (), diag::bridging_function_not_correct_type,
141
134
moduleName.str (), functionName);
142
135
llvm::report_fatal_error (" unable to set up the ObjC bridge!" );
@@ -153,16 +146,15 @@ getBridgingFn(Optional<SILDeclRef> &cacheSlot,
153
146
return *cacheSlot;
154
147
}
155
148
156
- #define REQUIRED (X ) { Types.get ##X##Type () }
157
- #define OPTIONAL (X ) { OptionalType::get (Types.get ##X##Type ()) }
158
- #define GENERIC (X ) None
149
+ #define REQUIRED (X ) Types.get##X##Type()
150
+ #define OPTIONAL (X ) OptionalType::get(Types.get##X##Type())
159
151
160
152
#define GET_BRIDGING_FN (Module, FromKind, FromTy, ToKind, ToTy ) \
161
153
SILDeclRef SILGenModule::get##FromTy##To##ToTy##Fn() { \
162
154
return getBridgingFn (FromTy##To##ToTy##Fn, *this , \
163
155
getASTContext ().Id_ ##Module, \
164
156
" _convert" #FromTy " To" #ToTy, \
165
- FromKind (FromTy), \
157
+ { FromKind (FromTy) } , \
166
158
ToKind (ToTy)); \
167
159
}
168
160
@@ -178,7 +170,6 @@ GET_BRIDGING_FN(WinSDK, REQUIRED, WindowsBool, REQUIRED, Bool)
178
170
#undef GET_BRIDGING_FN
179
171
#undef REQUIRED
180
172
#undef OPTIONAL
181
- #undef GENERIC
182
173
183
174
static FuncDecl *diagnoseMissingIntrinsic (SILGenModule &sgm,
184
175
SILLocation loc,
0 commit comments