@@ -556,8 +556,10 @@ static std::string encodeTypeInfo(const T &abiTypeInfo,
556
556
return std::move (typeEncodingOS.str ());
557
557
}
558
558
559
+ // Returns false if the given direct type is not yet supported because
560
+ // of its ABI.
559
561
template <class T >
560
- static void printDirectReturnOrParamCType (
562
+ static bool printDirectReturnOrParamCType (
561
563
const T &abiTypeInfo, Type valueType, const ModuleDecl *emittedModule,
562
564
raw_ostream &os, raw_ostream &cPrologueOS,
563
565
PrimitiveTypeMapping &typeMapping,
@@ -575,20 +577,21 @@ static void printDirectReturnOrParamCType(
575
577
576
578
unsigned Count = 0 ;
577
579
clang::CharUnits lastOffset;
578
- abiTypeInfo.enumerateRecordMembers (
579
- [&](clang::CharUnits offset, clang::CharUnits end, Type t) {
580
+ if ( abiTypeInfo.enumerateRecordMembers ([&](clang::CharUnits offset,
581
+ clang::CharUnits end, Type t) {
580
582
lastOffset = offset;
581
583
++Count;
582
584
addABIRecordToTypeEncoding (typeEncodingOS, offset, end, t, typeMapping);
583
- });
585
+ }))
586
+ return false ;
584
587
assert (Count > 0 && " missing return values" );
585
588
586
589
// FIXME: is this "prettyfying" logic sound for multiple return values?
587
590
if (isKnownCType (valueType, typeMapping) ||
588
591
(Count == 1 && lastOffset.isZero () && !valueType->hasTypeParameter () &&
589
592
valueType->isAnyClassReferenceType ())) {
590
593
prettifiedValuePrinter ();
591
- return ;
594
+ return true ;
592
595
}
593
596
594
597
os << " struct " << typeEncodingOS.str ();
@@ -642,6 +645,7 @@ static void printDirectReturnOrParamCType(
642
645
interopContext.runIfStubForDeclNotEmitted (typeEncodingOS.str (), [&]() {
643
646
printStub (cPrologueOS, typeEncodingOS.str ());
644
647
});
648
+ return true ;
645
649
}
646
650
647
651
// / Make adjustments to the Swift parameter name in generated C++, to
@@ -750,18 +754,20 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
750
754
if (!directResultType) {
751
755
os << " void" ;
752
756
} else {
753
- printDirectReturnOrParamCType (
754
- *directResultType, resultTy, emittedModule, os, cPrologueOS,
755
- typeMapping, interopContext, [&]() {
756
- OptionalTypeKind retKind;
757
- Type objTy;
758
- std::tie (objTy, retKind) =
759
- DeclAndTypePrinter::getObjectTypeAndOptionality (FD, resultTy);
760
-
761
- auto s = printClangFunctionReturnType (objTy, retKind, emittedModule,
762
- outputLang);
763
- assert (!s.isUnsupported ());
764
- });
757
+ if (!printDirectReturnOrParamCType (
758
+ *directResultType, resultTy, emittedModule, os, cPrologueOS,
759
+ typeMapping, interopContext, [&]() {
760
+ OptionalTypeKind retKind;
761
+ Type objTy;
762
+ std::tie (objTy, retKind) =
763
+ DeclAndTypePrinter::getObjectTypeAndOptionality (FD,
764
+ resultTy);
765
+
766
+ auto s = printClangFunctionReturnType (
767
+ objTy, retKind, emittedModule, outputLang);
768
+ assert (!s.isUnsupported ());
769
+ }))
770
+ return ClangRepresentation::unsupported;
765
771
}
766
772
} else {
767
773
OptionalTypeKind retKind;
0 commit comments