@@ -117,16 +117,16 @@ bool ModuleDependencyInfo::isTestableImport(StringRef moduleName) const {
117
117
}
118
118
119
119
void ModuleDependencyInfo::addOptionalModuleImport (
120
- StringRef module, llvm::StringSet<> *alreadyAddedModules) {
120
+ StringRef module, bool isExported, llvm::StringSet<> *alreadyAddedModules) {
121
121
if (!alreadyAddedModules || alreadyAddedModules->insert (module).second )
122
- storage->optionalModuleImports .push_back (module.str ());
122
+ storage->optionalModuleImports .push_back ({ module.str (), isExported} );
123
123
}
124
124
125
125
void ModuleDependencyInfo::addModuleImport (
126
- StringRef module, llvm::StringSet<> *alreadyAddedModules,
126
+ StringRef module, bool isExported, llvm::StringSet<> *alreadyAddedModules,
127
127
const SourceManager *sourceManager, SourceLoc sourceLocation) {
128
128
auto scannerImportLocToDiagnosticLocInfo =
129
- [&sourceManager](SourceLoc sourceLocation) {
129
+ [&sourceManager, isExported ](SourceLoc sourceLocation) {
130
130
auto lineAndColumnNumbers =
131
131
sourceManager->getLineAndColumnInBuffer (sourceLocation);
132
132
return ScannerImportStatementInfo::ImportDiagnosticLocationInfo (
@@ -137,14 +137,16 @@ void ModuleDependencyInfo::addModuleImport(
137
137
sourceManager->isOwning (sourceLocation);
138
138
139
139
if (alreadyAddedModules && alreadyAddedModules->contains (module)) {
140
- if (validSourceLocation) {
141
- // Find a prior import of this module and add import location
142
- for (auto &existingImport : storage->moduleImports ) {
143
- if (existingImport.importIdentifier == module) {
140
+ // Find a prior import of this module and add import location
141
+ // and adjust whether or not this module is ever imported as exported
142
+ for (auto &existingImport : storage->moduleImports ) {
143
+ if (existingImport.importIdentifier == module) {
144
+ if (validSourceLocation) {
144
145
existingImport.addImportLocation (
145
- scannerImportLocToDiagnosticLocInfo (sourceLocation));
146
- break ;
146
+ scannerImportLocToDiagnosticLocInfo (sourceLocation));
147
147
}
148
+ existingImport.isExported |= isExported;
149
+ break ;
148
150
}
149
151
}
150
152
} else {
@@ -153,15 +155,15 @@ void ModuleDependencyInfo::addModuleImport(
153
155
154
156
if (validSourceLocation)
155
157
storage->moduleImports .push_back (ScannerImportStatementInfo (
156
- module.str (), scannerImportLocToDiagnosticLocInfo (sourceLocation)));
158
+ module.str (), isExported, scannerImportLocToDiagnosticLocInfo (sourceLocation)));
157
159
else
158
160
storage->moduleImports .push_back (
159
- ScannerImportStatementInfo (module.str ()));
161
+ ScannerImportStatementInfo (module.str (), isExported ));
160
162
}
161
163
}
162
164
163
165
void ModuleDependencyInfo::addModuleImport (
164
- ImportPath::Module module, llvm::StringSet<> *alreadyAddedModules,
166
+ ImportPath::Module module, bool isExported, llvm::StringSet<> *alreadyAddedModules,
165
167
const SourceManager *sourceManager, SourceLoc sourceLocation) {
166
168
std::string ImportedModuleName = module.front ().Item .str ().str ();
167
169
auto submodulePath = module.getSubmodulePath ();
@@ -174,7 +176,7 @@ void ModuleDependencyInfo::addModuleImport(
174
176
alreadyAddedModules);
175
177
}
176
178
177
- addModuleImport (ImportedModuleName, alreadyAddedModules,
179
+ addModuleImport (ImportedModuleName, isExported, alreadyAddedModules,
178
180
sourceManager, sourceLocation);
179
181
}
180
182
@@ -203,7 +205,8 @@ void ModuleDependencyInfo::addModuleImports(
203
205
importDecl->isExported ()))
204
206
continue ;
205
207
206
- addModuleImport (realPath, &alreadyAddedModules, sourceManager,
208
+ addModuleImport (realPath, importDecl->isExported (),
209
+ &alreadyAddedModules, sourceManager,
207
210
importDecl->getLoc ());
208
211
209
212
// Additionally, keep track of which dependencies of a Source
0 commit comments