@@ -228,7 +228,7 @@ struct CountedByExpressionValidator
228228 case clang::BuiltinType::ULong:
229229 case clang::BuiltinType::LongLong:
230230 case clang::BuiltinType::ULongLong:
231- DLOG (" Ignoring count parameter with non-portable integer literal" );
231+ DLOG (" Ignoring count parameter with non-portable integer literal\n " );
232232 return false ;
233233 default :
234234 return true ;
@@ -330,7 +330,7 @@ struct UnaliasedInstantiationVisitor
330330 bool
331331 VisitTemplateSpecializationType (const clang::TemplateSpecializationType *) {
332332 hasUnaliasedInstantiation = true ;
333- DLOG (" Signature contains raw template, skipping" );
333+ DLOG (" Signature contains raw template, skipping\n " );
334334 return false ;
335335 }
336336};
@@ -340,15 +340,33 @@ struct ForwardDeclaredConcreteTypeVisitor
340340 bool hasForwardDeclaredConcreteType = false ;
341341 const clang::Module *Owner;
342342
343- ForwardDeclaredConcreteTypeVisitor (const clang::Module *Owner) : Owner(Owner) { ASSERT (Owner); };
343+ ForwardDeclaredConcreteTypeVisitor (const clang::Module *Owner) : Owner(Owner) {};
344344
345345 bool VisitRecordType (clang::RecordType *RT) {
346346 const clang::RecordDecl *RD = RT->getDecl ()->getDefinition ();
347347 ASSERT (RD && " pointer to concrete type without type definition?" );
348348 const clang::Module *M = RD->getOwningModule ();
349+
350+ if (!Owner && !M) {
351+ DLOG (" Both decls are in bridging header" );
352+ return true ;
353+ }
354+
355+ if (!Owner) {
356+ hasForwardDeclaredConcreteType = true ;
357+ DLOG (" Imported signature contains concrete type not available in bridging header, skipping\n " );
358+ LLVM_DEBUG (DUMP (RD));
359+ return false ;
360+ }
361+ if (!M) {
362+ ABORT ([RD](auto &out) {
363+ out << " Imported signature contains concrete type without an owning clang module:\n " ;
364+ RD->dump (out);
365+ });
366+ }
349367 if (!Owner->isModuleVisible (M)) {
350368 hasForwardDeclaredConcreteType = true ;
351- DLOG (" Imported signature contains concrete type not available in clang module, skipping" );
369+ DLOG (" Imported signature contains concrete type not available in clang module, skipping\n " );
352370 LLVM_DEBUG (DUMP (RD));
353371 return false ;
354372 }
@@ -415,7 +433,7 @@ static bool swiftifyImpl(ClangImporter::Implementation &Self,
415433 return false ;
416434
417435 if (ClangDecl->isImplicit ()) {
418- DLOG (" implicit functions lack lifetime and bounds info" );
436+ DLOG (" implicit functions lack lifetime and bounds info\n " );
419437 return false ;
420438 }
421439
@@ -427,6 +445,8 @@ static bool swiftifyImpl(ClangImporter::Implementation &Self,
427445 } else {
428446 OwningModule = ClangDecl->getOwningModule ();
429447 }
448+ bool IsInBridgingHeader = MappedDecl->getModuleContext ()->getName ().str () == CLANG_HEADER_MODULE_NAME;
449+ ASSERT (OwningModule || IsInBridgingHeader);
430450 ForwardDeclaredConcreteTypeVisitor CheckForwardDecls (OwningModule);
431451
432452 // We only attach the macro if it will produce an overload. Any __counted_by
@@ -620,7 +640,7 @@ void ClangImporter::Implementation::swiftify(AbstractFunctionDecl *MappedDecl) {
620640
621641 MacroDecl *SwiftifyImportDecl = dyn_cast_or_null<MacroDecl>(getKnownSingleDecl (SwiftContext, " _SwiftifyImport" ));
622642 if (!SwiftifyImportDecl) {
623- DLOG (" _SwiftifyImport macro not found" );
643+ DLOG (" _SwiftifyImport macro not found\n " );
624644 return ;
625645 }
626646
@@ -672,7 +692,7 @@ void ClangImporter::Implementation::swiftifyProtocol(
672692 MacroDecl *SwiftifyImportDecl = dyn_cast_or_null<MacroDecl>(
673693 getKnownSingleDecl (SwiftContext, " _SwiftifyImportProtocol" ));
674694 if (!SwiftifyImportDecl) {
675- DLOG (" _SwiftifyImportProtocol macro not found" );
695+ DLOG (" _SwiftifyImportProtocol macro not found\n " );
676696 return ;
677697 }
678698
0 commit comments