diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-01 22:20:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-01 22:20:10 +0000 |
commit | ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0 (patch) | |
tree | a836f1b947d7804a2b4a593ccbed8d25e02a5c31 /lib/Serialization/ASTReaderDecl.cpp | |
parent | 403bc3f85f3b3461b73abdd9c632980bf95f34bd (diff) |
Implement name hiding for declarations deserialized from a non-visible
module. When that module becomes visible, so do those declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 397671f85e..85cd72840a 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -86,6 +86,14 @@ namespace clang { Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); } + serialization::SubmoduleID readSubmoduleID(const RecordData &R, + unsigned &I) { + if (I >= R.size()) + return 0; + + return Reader.getGlobalSubmoduleID(F, R[I++]); + } + void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data, const RecordData &R, unsigned &I); @@ -253,10 +261,25 @@ void ASTDeclReader::VisitDecl(Decl *D) { D->setAccess((AccessSpecifier)Record[Idx++]); D->FromASTFile = true; D->ModulePrivate = Record[Idx++]; - - unsigned SubmoduleID = Record[Idx++]; - // FIXME: Actual use the submodule ID to determine visibility. - (void)SubmoduleID; + + // Determine whether this declaration is part of a (sub)module. If so, it + // may not yet be visible. + if (unsigned SubmoduleID = readSubmoduleID(Record, Idx)) { + // Module-private declarations are never visible, so there is no work to do. + if (!D->ModulePrivate) { + if (Module *Owner = Reader.getSubmodule(SubmoduleID)) { + if (Owner->NameVisibility != Module::AllVisible) { + // The owning module is not visible. Mark this declaration as + // module-private, + D->ModulePrivate = true; + + // Note that this declaration was hidden because its owning module is + // not yet visible. + Reader.HiddenNamesMap[Owner].push_back(D); + } + } + } + } } void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { |