Change ModuleDecl::getImportedModules to take an option set

...in preparation for me adding a third kind of import, making the
existing "All" kind a problem. NFC, except that I did rewrite the
ClangModuleUnit implementation of getImportedModules to be simpler!
This commit is contained in:
Jordan Rose
2018-12-13 17:45:06 -08:00
parent a62c87f6cd
commit 9ed3fe061d
18 changed files with 97 additions and 102 deletions

View File

@@ -1707,17 +1707,22 @@ public:
}
void collectImportedModules(llvm::StringSet<> &ImportedModules) {
ModuleDecl::ImportFilter ImportFilter;
ImportFilter |= ModuleDecl::ImportFilterKind::Public;
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
SmallVector<ModuleDecl::ImportedModule, 16> Imported;
SmallVector<ModuleDecl::ImportedModule, 16> FurtherImported;
CurrDeclContext->getParentSourceFile()->getImportedModules(Imported,
ModuleDecl::ImportFilter::All);
ImportFilter);
while (!Imported.empty()) {
ModuleDecl *MD = Imported.back().second;
Imported.pop_back();
if (!ImportedModules.insert(MD->getNameStr()).second)
continue;
FurtherImported.clear();
MD->getImportedModules(FurtherImported, ModuleDecl::ImportFilter::Public);
MD->getImportedModules(FurtherImported,
ModuleDecl::ImportFilterKind::Public);
Imported.append(FurtherImported.begin(), FurtherImported.end());
for (auto SubMod : FurtherImported) {
Imported.push_back(SubMod);
@@ -5331,9 +5336,12 @@ void CodeCompletionCallbacksImpl::doneParsing() {
Lookup.getToplevelCompletions(Request.OnlyTypes);
// Add results for all imported modules.
ModuleDecl::ImportFilter ImportFilter;
ImportFilter |= ModuleDecl::ImportFilterKind::Public;
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
SmallVector<ModuleDecl::ImportedModule, 4> Imports;
auto *SF = CurDeclContext->getParentSourceFile();
SF->getImportedModules(Imports, ModuleDecl::ImportFilter::All);
SF->getImportedModules(Imports, ImportFilter);
for (auto Imported : Imports) {
ModuleDecl *TheModule = Imported.second;