[BridgingHeaderChaining] Bind bridging header module when load module

When loading a module with embedded bridging header, bind the bridging
header module in the context when bridging header auto chaining is used.
This is because all the bridging header contents are chained into a PCH
file so binary module with bridging header should reference the PCH file
for all declarations.

rdar://148538787
This commit is contained in:
Steven Wu
2025-04-03 14:53:37 -07:00
parent 562d7dc832
commit 02ee2f4d62
4 changed files with 33 additions and 14 deletions

View File

@@ -165,15 +165,18 @@ ModuleFile::loadDependenciesForFileContext(const FileUnit *file,
if (dependency.isHeader()) {
// The path may be empty if the file being loaded is a partial AST,
// and the current compiler invocation is a merge-modules step.
if (!dependency.Core.RawPath.empty() &&
!M->getASTContext().SearchPathOpts.BridgingHeaderChaining) {
if (!dependency.Core.RawPath.empty()) {
// If using bridging header chaining, just bind the entire bridging
// header pch to the module. Otherwise, import the header.
bool hadError =
clangImporter->importHeader(dependency.Core.RawPath,
file->getParentModule(),
Core->importedHeaderInfo.fileSize,
Core->importedHeaderInfo.fileModTime,
Core->importedHeaderInfo.contents,
diagLoc);
M->getASTContext().SearchPathOpts.BridgingHeaderChaining
? clangImporter->bindBridgingHeader(file->getParentModule(),
diagLoc)
: clangImporter->importHeader(
dependency.Core.RawPath, file->getParentModule(),
Core->importedHeaderInfo.fileSize,
Core->importedHeaderInfo.fileModTime,
Core->importedHeaderInfo.contents, diagLoc);
if (hadError)
return error(Status::FailedToLoadBridgingHeader);
}