@@ -53,16 +53,18 @@ class ClangDiagnosticConsumer : public clang::TextDiagnosticPrinter {
5353 ~LoadModuleRAII () {
5454 if (Consumer) {
5555 // We must reset Clang's diagnostic engine here since we know that only
56- // the module lookup errors have been emitted. While the ClangDiagnosticConsumer
57- // takes care of filtering out the diagnostics from the output and from
58- // being handled by Swift's DiagnosticEngine, we must ensure to also
59- // reset Clang's DiagnosticEngine because its state is queried in later
60- // stages of compilation and errors emitted on "module_not_found" should not
61- // be counted.
62- // FIXME: We must instead allow for module loading in Clang to fail without
63- // needing to emit a diagnostic.
64- if (Engine && Consumer->CurrentImportNotFound && DiagEngineClearPriorToLookup)
65- Engine->Reset ();
56+ // the module lookup errors have been emitted. While the
57+ // ClangDiagnosticConsumer takes care of filtering out the diagnostics
58+ // from the output and from being handled by Swift's DiagnosticEngine,
59+ // we must ensure to also reset Clang's DiagnosticEngine because its
60+ // state is queried in later stages of compilation and errors emitted on
61+ // "module_not_found" should not be counted. Use a soft reset that only
62+ // clear the errors but not reset the states.
63+ // FIXME: We must instead allow for module loading in Clang to fail
64+ // without needing to emit a diagnostic.
65+ if (Engine && Consumer->CurrentImportNotFound &&
66+ DiagEngineClearPriorToLookup)
67+ Engine->Reset (/* soft=*/ true );
6668 Consumer->CurrentImport = nullptr ;
6769 Consumer->CurrentImportNotFound = false ;
6870 }
0 commit comments