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();
/// 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;
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)
{
: 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)
{
/// \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
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()) {
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)) {
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.