Introduce the notion of name visibility into modules. For a given
(sub)module, all of the names may be hidden, just the macro names may be exposed (for example, after the preprocessor has seen the import of the module but the parser has not), or all of the names may be exposed. Importing a module makes its names, and the names in any of its non-explicit submodules, visible to name lookup (transitively). This commit only introduces the notion of name visible and marks modules and submodules as visible when they are imported. The actual name-hiding logic in the AST reader will follow (along with test cases). llvm-svn: 145586
This commit is contained in:
@@ -1069,12 +1069,17 @@ static void compileModule(CompilerInstance &ImportingInstance,
|
||||
}
|
||||
|
||||
Module *CompilerInstance::loadModule(SourceLocation ImportLoc,
|
||||
ModuleIdPath Path) {
|
||||
ModuleIdPath Path,
|
||||
Module::NameVisibilityKind Visibility) {
|
||||
// If we've already handled this import, just return the cached result.
|
||||
// This one-element cache is important to eliminate redundant diagnostics
|
||||
// when both the preprocessor and parser see the same import declaration.
|
||||
if (!ImportLoc.isInvalid() && LastModuleImportLoc == ImportLoc)
|
||||
if (!ImportLoc.isInvalid() && LastModuleImportLoc == ImportLoc) {
|
||||
// Make the named module visible.
|
||||
if (LastModuleImportResult)
|
||||
ModuleManager->makeModuleVisible(LastModuleImportResult, Visibility);
|
||||
return LastModuleImportResult;
|
||||
}
|
||||
|
||||
// Determine what file we're searching from.
|
||||
SourceManager &SourceMgr = getSourceManager();
|
||||
@@ -1253,7 +1258,9 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc,
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Tell the AST reader to make the named submodule visible.
|
||||
// Make the named module visible.
|
||||
if (Module)
|
||||
ModuleManager->makeModuleVisible(Module, Visibility);
|
||||
|
||||
LastModuleImportLoc = ImportLoc;
|
||||
LastModuleImportResult = Module;
|
||||
|
||||
Reference in New Issue
Block a user