@@ -39,16 +39,24 @@ getKnownTypeInfo(const TypeDecl *typeDecl, PrimitiveTypeMapping &typeMapping,
3939 : typeMapping.getKnownCTypeInfo (typeDecl);
4040}
4141
42- bool isKnownCxxType (Type t, PrimitiveTypeMapping &typeMapping) {
42+ bool isKnownType (Type t, PrimitiveTypeMapping &typeMapping,
43+ OutputLanguageMode languageMode) {
4344 const TypeDecl *typeDecl;
4445 if (auto *typeAliasType = dyn_cast<TypeAliasType>(t.getPointer ()))
4546 typeDecl = typeAliasType->getDecl ();
4647 else if (auto *structDecl = t->getStructOrBoundGenericStruct ())
4748 typeDecl = structDecl;
4849 else
4950 return false ;
50- return getKnownTypeInfo (typeDecl, typeMapping, OutputLanguageMode::Cxx) !=
51- None;
51+ return getKnownTypeInfo (typeDecl, typeMapping, languageMode) != None;
52+ }
53+
54+ bool isKnownCxxType (Type t, PrimitiveTypeMapping &typeMapping) {
55+ return isKnownType (t, typeMapping, OutputLanguageMode::Cxx);
56+ }
57+
58+ bool isKnownCType (Type t, PrimitiveTypeMapping &typeMapping) {
59+ return isKnownType (t, typeMapping, OutputLanguageMode::ObjC);
5260}
5361
5462// Prints types in the C function signature that corresponds to the
@@ -164,6 +172,7 @@ void DeclAndTypeClangFunctionPrinter::printFunctionSignature(
164172 // Print out the return type.
165173 bool isIndirectReturnType =
166174 kind == FunctionSignatureKind::CFunctionProto &&
175+ !isKnownCType (resultTy, typeMapping) &&
167176 interopContext.getIrABIDetails ().shouldReturnIndirectly (resultTy);
168177 if (!isIndirectReturnType) {
169178 OptionalTypeKind retKind;
0 commit comments