@@ -117,16 +117,16 @@ bool ModuleDependencyInfo::isTestableImport(StringRef moduleName) const {
117117}
118118
119119void ModuleDependencyInfo::addOptionalModuleImport (
120- StringRef module , llvm::StringSet<> *alreadyAddedModules) {
120+ StringRef module , bool isExported, llvm::StringSet<> *alreadyAddedModules) {
121121 if (!alreadyAddedModules || alreadyAddedModules->insert (module ).second )
122- storage->optionalModuleImports .push_back (module .str ());
122+ storage->optionalModuleImports .push_back ({ module .str (), isExported} );
123123}
124124
125125void ModuleDependencyInfo::addModuleImport (
126- StringRef module , llvm::StringSet<> *alreadyAddedModules,
126+ StringRef module , bool isExported, llvm::StringSet<> *alreadyAddedModules,
127127 const SourceManager *sourceManager, SourceLoc sourceLocation) {
128128 auto scannerImportLocToDiagnosticLocInfo =
129- [&sourceManager](SourceLoc sourceLocation) {
129+ [&sourceManager, isExported ](SourceLoc sourceLocation) {
130130 auto lineAndColumnNumbers =
131131 sourceManager->getLineAndColumnInBuffer (sourceLocation);
132132 return ScannerImportStatementInfo::ImportDiagnosticLocationInfo (
@@ -137,14 +137,16 @@ void ModuleDependencyInfo::addModuleImport(
137137 sourceManager->isOwning (sourceLocation);
138138
139139 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) {
144145 existingImport.addImportLocation (
145- scannerImportLocToDiagnosticLocInfo (sourceLocation));
146- break ;
146+ scannerImportLocToDiagnosticLocInfo (sourceLocation));
147147 }
148+ existingImport.isExported |= isExported;
149+ break ;
148150 }
149151 }
150152 } else {
@@ -153,15 +155,15 @@ void ModuleDependencyInfo::addModuleImport(
153155
154156 if (validSourceLocation)
155157 storage->moduleImports .push_back (ScannerImportStatementInfo (
156- module .str (), scannerImportLocToDiagnosticLocInfo (sourceLocation)));
158+ module .str (), isExported, scannerImportLocToDiagnosticLocInfo (sourceLocation)));
157159 else
158160 storage->moduleImports .push_back (
159- ScannerImportStatementInfo (module .str ()));
161+ ScannerImportStatementInfo (module .str (), isExported ));
160162 }
161163}
162164
163165void ModuleDependencyInfo::addModuleImport (
164- ImportPath::Module module , llvm::StringSet<> *alreadyAddedModules,
166+ ImportPath::Module module , bool isExported, llvm::StringSet<> *alreadyAddedModules,
165167 const SourceManager *sourceManager, SourceLoc sourceLocation) {
166168 std::string ImportedModuleName = module .front ().Item .str ().str ();
167169 auto submodulePath = module .getSubmodulePath ();
@@ -174,7 +176,7 @@ void ModuleDependencyInfo::addModuleImport(
174176 alreadyAddedModules);
175177 }
176178
177- addModuleImport (ImportedModuleName, alreadyAddedModules,
179+ addModuleImport (ImportedModuleName, isExported, alreadyAddedModules,
178180 sourceManager, sourceLocation);
179181}
180182
@@ -203,7 +205,8 @@ void ModuleDependencyInfo::addModuleImports(
203205 importDecl->isExported ()))
204206 continue ;
205207
206- addModuleImport (realPath, &alreadyAddedModules, sourceManager,
208+ addModuleImport (realPath, importDecl->isExported (),
209+ &alreadyAddedModules, sourceManager,
207210 importDecl->getLoc ());
208211
209212 // Additionally, keep track of which dependencies of a Source
0 commit comments