diff options
-rw-r--r-- | include/clang/AST/Decl.h | 3 | ||||
-rw-r--r-- | include/clang/AST/DeclBase.h | 9 | ||||
-rw-r--r-- | include/clang/Sema/Lookup.h | 5 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 2 | ||||
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 8 |
5 files changed, 17 insertions, 10 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index f27330b7ac..bbd3ef3a20 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -195,6 +195,9 @@ public: ModulePrivate = MP; } + /// \brief Determine whether this declaration is hidden from name lookup. + bool isHidden() const { return Hidden; } + /// \brief Determine whether this declaration is a C++ class member. bool isCXXClassMember() const { const DeclContext *DC = getDeclContext(); diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 09e1fdcd63..c2303bcf51 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -263,6 +263,11 @@ protected: /// defined. unsigned ModulePrivate : 1; + /// \brief Whether this declaration is hidden from normal name lookup, e.g., + /// because it is was loaded from an AST file is either module-private or + /// because its submodule has not been made visible. + unsigned Hidden : 1; + /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in. unsigned IdentifierNamespace : 12; @@ -290,7 +295,7 @@ protected: Loc(L), DeclKind(DK), InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false), Referenced(false), TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0), - ModulePrivate(0), + ModulePrivate(0), Hidden(0), IdentifierNamespace(getIdentifierNamespaceForKind(DK)), HasCachedLinkage(0) { @@ -301,7 +306,7 @@ protected: : NextDeclInContext(0), DeclKind(DK), InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false), Referenced(false), TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0), - ModulePrivate(0), + ModulePrivate(0), Hidden(0), IdentifierNamespace(getIdentifierNamespaceForKind(DK)), HasCachedLinkage(0) { diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index 6486e53bed..1c24d20ee8 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -275,9 +275,8 @@ public: /// \brief Determine whether the given declaration is visible to the /// program. static bool isVisible(NamedDecl *D) { - // So long as this declaration is not module-private or was parsed as - // part of this translation unit (i.e., in the module), it's visible. - if (!D->isModulePrivate() || !D->isFromASTFile()) + // If this declaration is not hidden, it's visible. + if (!D->isHidden()) return true; // FIXME: We should be allowed to refer to a module-private name from diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 2864fcf48b..df158599de 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2496,7 +2496,7 @@ ASTReader::ASTReadResult ASTReader::validateFileEntries(ModuleFile &M) { void ASTReader::makeNamesVisible(const HiddenNames &Names) { for (unsigned I = 0, N = Names.size(); I != N; ++I) { if (Decl *D = Names[I].dyn_cast<Decl *>()) - D->ModulePrivate = false; + D->Hidden = false; else { IdentifierInfo *II = Names[I].get<IdentifierInfo *>(); if (!II->hasMacroDefinition()) { diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 0672129f1e..6a88313f74 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -364,7 +364,8 @@ void ASTDeclReader::VisitDecl(Decl *D) { D->setAccess((AccessSpecifier)Record[Idx++]); D->FromASTFile = true; D->ModulePrivate = Record[Idx++]; - + D->Hidden = D->ModulePrivate; + // Determine whether this declaration is part of a (sub)module. If so, it // may not yet be visible. if (unsigned SubmoduleID = readSubmoduleID(Record, Idx)) { @@ -372,9 +373,8 @@ void ASTDeclReader::VisitDecl(Decl *D) { 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; + // The owning module is not visible. Mark this declaration as hidden. + D->Hidden = true; // Note that this declaration was hidden because its owning module is // not yet visible. |