Attach Lazy ClangImporter Diagnostics as Notes

Clang importer diagnostics that are produced as a result of a reference
in Swift code are attached to as notes to the Sema produced diagnostic
that indicates the declaration is unavailable.

Ex: Notes about why a C function import failed are attached to
the error explaining that the symbol could not be found in scope.
This commit is contained in:
Nuri Amari
2022-01-28 18:46:12 -05:00
parent 9e93369a33
commit 3762ca1fa7
25 changed files with 396 additions and 336 deletions

View File

@@ -3626,6 +3626,11 @@ bool MissingMemberFailure::diagnoseAsError() {
emitDiagnostic(diagnostic, baseType, getName())
.highlight(getSourceRange())
.highlight(nameLoc.getSourceRange());
const auto &ctx = getSolution().getDC()->getASTContext();
if (ctx.LangOpts.EnableExperimentalClangImporterDiagnostics) {
ctx.getClangModuleLoader()->diagnoseMemberValue(getName().getFullName(),
baseType);
}
};
TypoCorrectionResults corrections(getName(), nameLoc);