summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-12-01 17:11:21 +0000
committerDouglas Gregor <dgregor@apple.com>2011-12-01 17:11:21 +0000
commitff2be53f8f15a74f044d95b70706ec0d9dcace5f (patch)
treea6df83747b5f531742fff0e1fc258c0f21192f8c /clang/lib/Serialization/ASTReader.cpp
parent719051e1c6ba05f45f3c83124354bc856bd59e8f (diff)
downloadbcm5719-llvm-ff2be53f8f15a74f044d95b70706ec0d9dcace5f.tar.gz
bcm5719-llvm-ff2be53f8f15a74f044d95b70706ec0d9dcace5f.zip
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
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index d43f8c1f45d..258baebc05c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2439,6 +2439,38 @@ ASTReader::ASTReadResult ASTReader::validateFileEntries(ModuleFile &M) {
return Success;
}
+void ASTReader::makeModuleVisible(Module *Mod,
+ Module::NameVisibilityKind NameVisibility) {
+ llvm::SmallPtrSet<Module *, 4> Visited;
+ llvm::SmallVector<Module *, 4> Stack;
+ Stack.push_back(Mod);
+ while (!Stack.empty()) {
+ Mod = Stack.back();
+ Stack.pop_back();
+
+ if (NameVisibility <= Mod->NameVisibility) {
+ // This module already has this level of visibility (or greater), so
+ // there is nothing more to do.
+ continue;
+ }
+
+ // Update the module's name visibility.
+ Mod->NameVisibility = NameVisibility;
+
+ // FIXME: If we've already deserialized any names from this module,
+ // mark them as visible.
+
+ // Push any non-explicit submodules onto the stack to be marked as
+ // visible.
+ for (llvm::StringMap<Module *>::iterator Sub = Mod->SubModules.begin(),
+ SubEnd = Mod->SubModules.end();
+ Sub != SubEnd; ++Sub) {
+ if (!Sub->getValue()->IsExplicit && Visited.insert(Sub->getValue()))
+ Stack.push_back(Sub->getValue());
+ }
+ }
+}
+
ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
ModuleKind Type) {
switch(ReadASTCore(FileName, Type, /*ImportedBy=*/0)) {
OpenPOWER on IntegriCloud