Skip to content

Commit 7c5d74e

Browse files
authored
Merge pull request swiftlang#30325 from gribozavr/unhack-getBridgingFn
2 parents 77dee31 + 6813762 commit 7c5d74e

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,8 @@ getBridgingFn(Optional<SILDeclRef> &cacheSlot,
7575
SILGenModule &SGM,
7676
Identifier moduleName,
7777
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) {
8480
if (!cacheSlot) {
8581
ASTContext &ctx = SGM.M.getASTContext();
8682
ModuleDecl *mod = ctx.getLoadedModule(moduleName);
@@ -122,21 +118,18 @@ getBridgingFn(Optional<SILDeclRef> &cacheSlot,
122118
return SGM.Types.getLoweredType(ty, TypeExpansionContext::minimal());
123119
};
124120

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!");
136130
}
137131

138-
if (outputType
139-
&& fnConv.getSingleSILResultType() != toSILType(*outputType)) {
132+
if (fnConv.getSingleSILResultType() != toSILType(outputType)) {
140133
SGM.diagnose(fd->getLoc(), diag::bridging_function_not_correct_type,
141134
moduleName.str(), functionName);
142135
llvm::report_fatal_error("unable to set up the ObjC bridge!");
@@ -153,16 +146,15 @@ getBridgingFn(Optional<SILDeclRef> &cacheSlot,
153146
return *cacheSlot;
154147
}
155148

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())
159151

160152
#define GET_BRIDGING_FN(Module, FromKind, FromTy, ToKind, ToTy) \
161153
SILDeclRef SILGenModule::get##FromTy##To##ToTy##Fn() { \
162154
return getBridgingFn(FromTy##To##ToTy##Fn, *this, \
163155
getASTContext().Id_##Module, \
164156
"_convert" #FromTy "To" #ToTy, \
165-
FromKind(FromTy), \
157+
{ FromKind(FromTy) }, \
166158
ToKind(ToTy)); \
167159
}
168160

@@ -178,7 +170,6 @@ GET_BRIDGING_FN(WinSDK, REQUIRED, WindowsBool, REQUIRED, Bool)
178170
#undef GET_BRIDGING_FN
179171
#undef REQUIRED
180172
#undef OPTIONAL
181-
#undef GENERIC
182173

183174
static FuncDecl *diagnoseMissingIntrinsic(SILGenModule &sgm,
184175
SILLocation loc,

0 commit comments

Comments
 (0)