Skip to content

Commit 7cdb285

Browse files
authored
Merge pull request swiftlang#28776 from DougGregor/clang-diag-consumer-bridging-pch
2 parents f1e690c + 34a883d commit 7cdb285

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,11 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
800800
auto FID = clangSrcMgr.createFileID(
801801
llvm::make_unique<ZeroFilledMemoryBuffer>(1, "<main>"));
802802
clangSrcMgr.setMainFileID(FID);
803+
auto &diagConsumer = CI.getDiagnosticClient();
804+
diagConsumer.BeginSourceFile(CI.getLangOpts());
805+
SWIFT_DEFER {
806+
diagConsumer.EndSourceFile();
807+
};
803808

804809
// Pass in TU_Complete, which is the default mode for the Preprocessor
805810
// constructor and the right one for reading a PCH.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* No content */
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework module PrivateWarning {
2+
header "PrivateWarning.h"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework module PrivateWarning.Private {
2+
header "PrivateWarning_Private.h"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* No content */
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import PrivateWarning;
2+
@import PrivateWarning.Private;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: rm -f %t.*
2+
// REQUIRES: objc_interop
3+
4+
// Build a bridging PCH for involving a module map that contains a warning
5+
// RUN: %target-swift-frontend -F %S/Inputs/ModuleMapWarning -emit-pch %S/Inputs/ModuleMapWarning/bridging-pch.h -pch-output-dir %t/pch 2> %t.stderr
6+
// RUN: %FileCheck %s < %t.stderr
7+
8+
// CHECK: module.private.modulemap:1:33: warning: private submodule 'PrivateWarning.Private' in private module map, expected top-level module
9+
10+
// Check that loading that bridging PCH Does not crash the compiler.
11+
// RUN: %target-swift-frontend -F %S/Inputs/ModuleMapWarning -import-objc-header %S/Inputs/ModuleMapWarning/bridging-pch.h -pch-output-dir %t/pch -typecheck %s
12+
13+

0 commit comments

Comments
 (0)