Skip to content

Commit 95e93ba

Browse files
Merge pull request #77925 from cachemeifyoucan/eng/PR-139723218
2 parents ec5bee8 + 04f09d6 commit 95e93ba

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/ClangImporter/ClangDiagnosticConsumer.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)