File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -4402,12 +4402,24 @@ ClangImporter::Implementation::importDiagnosticTargetFromLookupTableEntry(
4402
4402
" MacroInfo or ModuleMacro pointer" );
4403
4403
}
4404
4404
4405
+ static void diagnoseForeignReferenceTypeFixit (ClangImporter::Implementation &Impl,
4406
+ HeaderLoc loc, Diagnostic diag) {
4407
+ auto importedLoc =
4408
+ Impl.SwiftContext .getClangModuleLoader ()->importSourceLocation (loc.clangLoc );
4409
+ Impl.diagnose (loc, diag)
4410
+ .fixItInsert (importedLoc, " SWIFT_REFERENCE_TYPE(<#retain#>, <#release#>) " );
4411
+ }
4412
+
4405
4413
bool ClangImporter::Implementation::emitDiagnosticsForTarget (
4406
4414
ImportDiagnosticTarget target, clang::SourceLocation fallbackLoc) {
4407
4415
for (auto it = ImportDiagnostics[target].rbegin ();
4408
4416
it != ImportDiagnostics[target].rend (); ++it) {
4409
4417
HeaderLoc loc = HeaderLoc (it->loc .isValid () ? it->loc : fallbackLoc);
4410
- diagnose (loc, it->diag );
4418
+ if (it->diag .getID () == diag::record_not_automatically_importable.ID ) {
4419
+ diagnoseForeignReferenceTypeFixit (*this , loc, it->diag );
4420
+ } else {
4421
+ diagnose (loc, it->diag );
4422
+ }
4411
4423
}
4412
4424
return ImportDiagnostics[target].size ();
4413
4425
}
Original file line number Diff line number Diff line change @@ -917,10 +917,10 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
917
917
// / interface. Use this to diagnose issues with declarations that are not
918
918
// / imported or that are not reflected in a generated interface.
919
919
template <typename ...Args>
920
- void diagnose (HeaderLoc loc, Args &&...args) {
920
+ InFlightDiagnostic diagnose (HeaderLoc loc, Args &&...args) {
921
921
// If we're in the middle of pretty-printing, suppress diagnostics.
922
922
if (SwiftContext.Diags .isPrettyPrintingDecl ()) {
923
- return ;
923
+ return InFlightDiagnostic () ;
924
924
}
925
925
926
926
auto swiftLoc = loc.fallbackLoc ;
@@ -932,7 +932,7 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
932
932
loc.clangLoc );
933
933
}
934
934
935
- SwiftContext.Diags .diagnose (swiftLoc, std::forward<Args>(args)...);
935
+ return SwiftContext.Diags .diagnose (swiftLoc, std::forward<Args>(args)...);
936
936
}
937
937
938
938
void addImportDiagnostic (
You can’t perform that action at this time.
0 commit comments