Skip to content

Commit d33f404

Browse files
committed
[ClangImporter] Allow importing modules even if there's a fatal Clang error.
This was supposed to prevent crashes, but it ended up /causing/ crashes because we may hit a fatal Clang error /while/ importing Clang modules and bridging headers. I left the test on the logic that imports bridging headers because that happens under more controlled circumstances. (Clang modules that have Swift counterparts should never have bridging headers.) rdar://problem/21689014 Swift SVN r30512
1 parent 9aa5ff1 commit d33f404

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -827,13 +827,7 @@ std::string ClangImporter::getBridgingHeaderContents(StringRef headerPath,
827827
Module *ClangImporter::loadModule(
828828
SourceLoc importLoc,
829829
ArrayRef<std::pair<Identifier, SourceLoc>> path) {
830-
// Don't even try to load the module if the Clang context is in a bad way.
831-
// It could cause a crash.
832830
auto &clangContext = Impl.getClangASTContext();
833-
auto &clangDiags = clangContext.getDiagnostics();
834-
if (clangDiags.hasFatalErrorOccurred())
835-
return nullptr;
836-
837831
auto &clangHeaderSearch = Impl.getClangPreprocessor().getHeaderSearchInfo();
838832

839833
// Look up the top-level module first, to see if it exists at all.

test/ClangModules/sdk-bridging-header.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// RUN: %target-swift-frontend -parse -verify %s -import-objc-header %S/Inputs/sdk-bridging-header.h
2+
// RUN: not %target-swift-frontend -parse %s -import-objc-header %S/Inputs/bad-bridging-header.h 2>&1 | FileCheck -check-prefix=CHECK-FATAL %s
3+
4+
// CHECK-FATAL: failed to import bridging header
25

36
// REQUIRES: objc_interop
47

0 commit comments

Comments
 (0)