Do not inherit search paths from loaded binary Swift module dependencies in Swift 6

This commit is contained in:
Artem Chikin
2023-09-21 08:44:37 -07:00
parent 9f61777eb0
commit cc3528900d
3 changed files with 16 additions and 2 deletions

View File

@@ -271,8 +271,10 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
}
StringRef SDKPath = ctx.SearchPathOpts.getSDKPath();
if (SDKPath.empty() ||
!Core->ModuleInputBuffer->getBufferIdentifier().startswith(SDKPath)) {
// In Swift 6 mode, we do not inherit search paths from loaded non-SDK modules.
if (!ctx.LangOpts.isSwiftVersionAtLeast(6) &&
(SDKPath.empty() ||
!Core->ModuleInputBuffer->getBufferIdentifier().startswith(SDKPath))) {
for (const auto &searchPath : Core->SearchPaths) {
ctx.addSearchPath(
ctx.SearchPathOpts.SearchPathRemapper.remapPath(searchPath.Path),