@@ -564,10 +564,10 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
564
564
565
565
auto directResultType = signature->getDirectResultType ();
566
566
// FIXME: support direct + indirect results.
567
- if (directResultType && signature->getNumIndirectResults () > 0 )
567
+ if (directResultType && signature->getNumIndirectResultValues () > 0 )
568
568
return ClangRepresentation::unsupported;
569
569
// FIXME: support multiple indirect results.
570
- if (signature->getNumIndirectResults () > 1 )
570
+ if (signature->getNumIndirectResultValues () > 1 )
571
571
return ClangRepresentation::unsupported;
572
572
573
573
if (!directResultType) {
@@ -608,16 +608,6 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
608
608
bool HasParams = false ;
609
609
610
610
if (kind == FunctionSignatureKind::CFunctionProto) {
611
- // Indirect result is passed in as the first parameter.
612
- // FIXME: make visitor!
613
- for (const auto &result : signature->getIndirectResultTypes ()) {
614
- HasParams = true ;
615
- if (result.hasSRet ())
616
- os << " SWIFT_INDIRECT_RESULT " ;
617
- // FIXME: it would be nice to print out the C struct type here.
618
- os << " void * _Nonnull" ;
619
- }
620
-
621
611
// First, verify that the C++ param types are representable.
622
612
for (auto param : *FD->getParameters ()) {
623
613
OptionalTypeKind optKind;
@@ -636,7 +626,7 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
636
626
return resultingRepresentation;
637
627
}
638
628
639
- bool NeedsComma = HasParams ;
629
+ bool NeedsComma = false ;
640
630
auto emitNewParam = [&]() {
641
631
HasParams = true ;
642
632
if (NeedsComma)
@@ -667,6 +657,14 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
667
657
assert (!s.isUnsupported ());
668
658
};
669
659
signature->visitParameterList (
660
+ [&](const IRABIDetailsProvider::LoweredFunctionSignature::
661
+ IndirectResultValue &indirectResult) {
662
+ emitNewParam ();
663
+ if (indirectResult.hasSRet ())
664
+ os << " SWIFT_INDIRECT_RESULT " ;
665
+ // FIXME: it would be nice to print out the C struct type here.
666
+ os << " void * _Nonnull" ;
667
+ },
670
668
[&](const IRABIDetailsProvider::LoweredFunctionSignature::
671
669
DirectParameter ¶m) {
672
670
emitNewParam ();
@@ -744,7 +742,7 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
744
742
->isAnyClassReferenceType ()))
745
743
os << " const " ;
746
744
os << " void * _Nonnull _self" ;
747
- } else if (param.role == AdditionalParam::Role::Error) {
745
+ } else if (param.role == AdditionalParam::Role::Error) {
748
746
os << " SWIFT_ERROR_RESULT " ;
749
747
os << " void * _Nullable * _Nullable _error" ;
750
748
} else if (param.role == AdditionalParam::Role::GenericRequirement) {
@@ -840,21 +838,17 @@ void DeclAndTypeClangFunctionPrinter::printCxxThunkBody(
840
838
os << cxx_synthesis::getCxxImplNamespaceName () << " ::" << swiftSymbolName
841
839
<< ' (' ;
842
840
843
- bool hasParams = false ;
844
- if (additionalParam) {
845
- hasParams = true ;
846
- os << *additionalParam;
847
- }
848
-
849
- bool needsComma = hasParams;
841
+ bool needsComma = false ;
850
842
size_t paramIndex = 1 ;
851
- auto printParamUse = [&](const ParamDecl ¶m, bool isIndirect,
852
-
853
- std::string directTypeEncoding) {
843
+ auto emitNewParam = [&]() {
854
844
if (needsComma)
855
845
os << " , " ;
856
846
needsComma = true ;
857
- hasParams = true ;
847
+ };
848
+ auto printParamUse = [&](const ParamDecl ¶m, bool isIndirect,
849
+
850
+ std::string directTypeEncoding) {
851
+ emitNewParam ();
858
852
std::string paramName;
859
853
if (param.isSelfParameter ()) {
860
854
paramName = " *this" ;
@@ -872,6 +866,13 @@ void DeclAndTypeClangFunctionPrinter::printCxxThunkBody(
872
866
};
873
867
874
868
signature->visitParameterList (
869
+ [&](const IRABIDetailsProvider::LoweredFunctionSignature::
870
+ IndirectResultValue &) {
871
+ emitNewParam ();
872
+ assert (additionalParam);
873
+ os << *additionalParam;
874
+ additionalParam = None;
875
+ },
875
876
[&](const IRABIDetailsProvider::LoweredFunctionSignature::
876
877
DirectParameter ¶m) {
877
878
printParamUse (
@@ -885,7 +886,7 @@ void DeclAndTypeClangFunctionPrinter::printCxxThunkBody(
885
886
});
886
887
887
888
if (additionalParams.size ()) {
888
- if (hasParams )
889
+ if (needsComma )
889
890
os << " , " ;
890
891
interleaveComma (additionalParams, os, [&](const AdditionalParam ¶m) {
891
892
if (param.role == AdditionalParam::Role::GenericRequirement) {
0 commit comments