Skip to content

Commit 332255b

Browse files
authored
Merge pull request swiftlang#69419 from artemcm/NoBuiltinModuleScan
[Dependency Scanning] Special-case imports of the 'Builtin' module not referencing an "actual" module
2 parents 21fdca9 + 4a0a2f3 commit 332255b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lib/AST/ModuleDependencies.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ void ModuleDependencyInfo::addModuleImport(
136136

137137
ImportPath::Builder scratch;
138138
auto realPath = importDecl->getRealModulePath(scratch);
139+
140+
// Explicit 'Builtin' import is not a part of the module's
141+
// dependency set, does not exist on the filesystem,
142+
// and is resolved within the compiler during compilation.
143+
SmallString<64> importedModuleName;
144+
realPath.getString(importedModuleName);
145+
if (importedModuleName == BUILTIN_NAME)
146+
continue;
147+
139148
addModuleImport(realPath, &alreadyAddedModules);
140149

141150
// Additionally, keep track of which dependencies of a Source
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -module-name HasBuiltinImport -enable-builtin-module
3+
import Builtin
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/clang-module-cache)
3+
4+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -verify
5+
// RUN: %validate-json %t/deps.json | %FileCheck %s
6+
7+
import HasBuiltinImport
8+
9+
// CHECK: "mainModuleName": "deps"
10+

0 commit comments

Comments
 (0)