@@ -2597,34 +2597,30 @@ namespace {
25972597 result->addMember (ctor);
25982598 }
25992599 } else {
2600- if (!Impl.SwiftContext .LangOpts .hasFeature (
2601- Feature::SuppressCXXForeignReferenceTypeInitializers)) {
2602- assert (
2603- isa<ClassDecl>(result) &&
2604- " Expected result to be a ClassDecl as it cannot be a StructDecl" );
2605- // When we add full support for C foreign reference types then we
2606- // should synthesize static factories for them as well
2607- if (auto *cxxRecordDecl = dyn_cast<clang::CXXRecordDecl>(decl)) {
2608- bool hasUserProvidedStaticFactory = llvm::any_of (
2609- cxxRecordDecl->methods (),
2610- [](const clang::CXXMethodDecl *method) {
2611- return method->isStatic () &&
2612- llvm::any_of (
2613- method->specific_attrs <clang::SwiftNameAttr>(),
2614- [](const auto *attr) {
2615- return attr->getName ().starts_with (" init(" );
2616- });
2617- });
2618- if (!hasUserProvidedStaticFactory) {
2619- auto generatedCxxMethodDecls =
2620- synthesizer.synthesizeStaticFactoryForCXXForeignRef (
2621- cxxRecordDecl);
2622- for (auto *methodDecl : generatedCxxMethodDecls) {
2623- if (Decl *importedInitDecl =
2624- Impl.SwiftContext .getClangModuleLoader ()
2625- ->importDeclDirectly (methodDecl))
2626- result->addMember (importedInitDecl);
2627- }
2600+ assert (
2601+ isa<ClassDecl>(result) &&
2602+ " Expected result to be a ClassDecl as it cannot be a StructDecl" );
2603+ // When we add full support for C foreign reference types then we
2604+ // should synthesize static factories for them as well
2605+ if (auto *cxxRecordDecl = dyn_cast<clang::CXXRecordDecl>(decl)) {
2606+ bool hasUserProvidedStaticFactory = llvm::any_of (
2607+ cxxRecordDecl->methods (), [](const clang::CXXMethodDecl *method) {
2608+ return method->isStatic () &&
2609+ llvm::any_of (
2610+ method->specific_attrs <clang::SwiftNameAttr>(),
2611+ [](const auto *attr) {
2612+ return attr->getName ().starts_with (" init(" );
2613+ });
2614+ });
2615+ if (!hasUserProvidedStaticFactory) {
2616+ auto generatedCxxMethodDecls =
2617+ synthesizer.synthesizeStaticFactoryForCXXForeignRef (
2618+ cxxRecordDecl);
2619+ for (auto *methodDecl : generatedCxxMethodDecls) {
2620+ if (Decl *importedInitDecl =
2621+ Impl.SwiftContext .getClangModuleLoader ()
2622+ ->importDeclDirectly (methodDecl))
2623+ result->addMember (importedInitDecl);
26282624 }
26292625 }
26302626 }
0 commit comments