@@ -1249,45 +1249,38 @@ void DeclAndTypeClangFunctionPrinter::printCxxThunkBody(
1249
1249
os << " #else\n " ;
1250
1250
if (resultTy->isVoid ()) {
1251
1251
os << " return SWIFT_RETURN_THUNK(void, Swift::Error(opaqueError));\n " ;
1252
+ os << " #endif\n " ;
1252
1253
} else {
1253
- os << " return SWIFT_RETURN_THUNK(" ;
1254
1254
auto directResultType = signature.getDirectResultType ();
1255
1255
printDirectReturnOrParamCType (
1256
1256
*directResultType, resultTy, moduleContext, os, cPrologueOS,
1257
1257
typeMapping, interopContext, [&]() {
1258
+ os << " return SWIFT_RETURN_THUNK(" ;
1258
1259
OptionalTypeKind retKind;
1259
1260
Type objTy;
1260
1261
std::tie (objTy, retKind) =
1261
1262
DeclAndTypePrinter::getObjectTypeAndOptionality (FD, resultTy);
1262
1263
1263
1264
auto s = printClangFunctionReturnType (objTy, retKind, const_cast <ModuleDecl *>(moduleContext),
1264
1265
OutputLanguageMode::Cxx);
1266
+ os << " , Swift::Error(opaqueError));\n " ;
1267
+ os << " #endif\n " ;
1268
+
1269
+ // Return the function result value if it doesn't throw.
1270
+ if (!resultTy->isVoid () && hasThrows) {
1271
+ os << " \n " ;
1272
+ os << " return SWIFT_RETURN_THUNK(" ;
1273
+ printClangFunctionReturnType (
1274
+ objTy, retKind, const_cast <ModuleDecl *>(moduleContext),
1275
+ OutputLanguageMode::Cxx);
1276
+ os << " , returnValue);\n " ;
1277
+ }
1278
+
1265
1279
assert (!s.isUnsupported ());
1266
1280
});
1267
- os << " , Swift::Error(opaqueError));\n " ;
1268
1281
}
1269
- os << " #endif\n " ;
1270
1282
}
1271
1283
1272
- // Return the function result value if it doesn't throw.
1273
- if (!resultTy->isVoid () && hasThrows) {
1274
- os << " \n " ;
1275
- os << " return SWIFT_RETURN_THUNK(" ;
1276
- auto directResultType = signature.getDirectResultType ();
1277
- printDirectReturnOrParamCType (
1278
- *directResultType, resultTy, moduleContext, os, cPrologueOS,
1279
- typeMapping, interopContext, [&]() {
1280
- OptionalTypeKind retKind;
1281
- Type objTy;
1282
- std::tie (objTy, retKind) =
1283
- DeclAndTypePrinter::getObjectTypeAndOptionality (FD, resultTy);
1284
-
1285
- auto s = printClangFunctionReturnType (objTy, retKind, const_cast <ModuleDecl *>(moduleContext),
1286
- OutputLanguageMode::Cxx);
1287
- assert (!s.isUnsupported ());
1288
- });
1289
- os << " , returnValue);\n " ;
1290
- }
1291
1284
}
1292
1285
1293
1286
static StringRef getConstructorName (const AbstractFunctionDecl *FD) {
0 commit comments