Skip to content

Commit d30d4bc

Browse files
authored
[ClangImporter] Honor -show-diagnostics-after-fatal. (#10808)
Clang's equivalent of this is mapping fatal errors to non-fatal errors. This isn't something we really care about for users since it's so rare, but we do use it in our tests, like this one that's been disabled for a long time. rdar://problem/30287833
1 parent fda424b commit d30d4bc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,15 @@ ClangImporter::create(ASTContext &ctx,
904904

905905
// Don't stop emitting messages if we ever can't load a module.
906906
// FIXME: This is actually a general problem: any "fatal" error could mess up
907-
// the CompilerInvocation.
907+
// the CompilerInvocation when we're not in "show diagnostics after fatal
908+
// error" mode.
908909
clangDiags->setSeverity(clang::diag::err_module_not_found,
909910
clang::diag::Severity::Error,
910911
clang::SourceLocation());
911912
clangDiags->setSeverity(clang::diag::err_module_not_built,
912913
clang::diag::Severity::Error,
913914
clang::SourceLocation());
915+
clangDiags->setFatalsAsError(ctx.Diags.getShowDiagnosticsAfterFatalError());
914916

915917
// Create an almost-empty memory buffer.
916918
auto sourceBuffer = llvm::MemoryBuffer::getMemBuffer(
@@ -1083,7 +1085,7 @@ bool ClangImporter::Implementation::importHeader(
10831085
// Don't even try to load the bridging header if the Clang AST is in a bad
10841086
// state. It could cause a crash.
10851087
auto &clangDiags = getClangASTContext().getDiagnostics();
1086-
if (clangDiags.hasFatalErrorOccurred())
1088+
if (clangDiags.hasUnrecoverableErrorOccurred())
10871089
return true;
10881090

10891091
assert(adapter);

test/ClangImporter/MixedSource/broken-modules.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// RUN: not %target-swift-frontend -typecheck %s -import-objc-header %S/../../Inputs/empty.swift 2>&1 | %FileCheck -check-prefix=EMPTY-HEADER %s
99

1010
// REQUIRES: objc_interop
11-
// REQUIRES: rdar30287833
1211

1312
// EMPTY-HEADER-NOT: header
1413

0 commit comments

Comments
 (0)