[Dependency Scanning] Only optionally try to resolve imports of 'Foo.Private' submodules to 'Foo_Private' top-level modules. Such a module may not actually exist and the user did in fact mean a submodule, in which case we do not want to error out during the scan

This commit is contained in:
Artem Chikin
2023-09-28 11:28:42 -07:00
parent d04741937c
commit 04eb35b7e3
5 changed files with 14 additions and 3 deletions

View File

@@ -724,7 +724,7 @@ public:
// Special case: a submodule named "Foo.Private" can be moved to a top-level
// module named "Foo_Private". ClangImporter has special support for this.
if (submoduleComponent.Item.str() == "Private")
ImportedModuleName = ImportedModuleName + "_Private";
addOptionalModuleImport(ImportedModuleName + "_Private", alreadyAddedModules);
}
addModuleImport(ImportedModuleName, alreadyAddedModules);

View File

@@ -0,0 +1 @@
void funcY(void);

View File

@@ -0,0 +1 @@
void funcYPrivate(void);

View File

@@ -46,3 +46,10 @@ module X_Private {
header "X_Private.h"
export *
}
module Y {
header "Y.h"
export *
explicit module Private {
header "Y_Private.h"
}
}

View File

@@ -1,7 +1,9 @@
// RUN: %empty-directory(%t.module-cache)
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache %s -o %t.deps.json -I %S/Inputs/CHeaders
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache %s -o %t.deps.json -I %S/Inputs/CHeaders -verify
// RUN: %validate-json %t.deps.json | %FileCheck %s
// CHECK: "clang": "X_Private"
// CHECK: "clang": "Y"
// CHECK-NOT: "clang": "Y_Private"
import X.Private
import Y.Private