mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:54:41 +01:00
[clang] Rename Decl::isHidden() to isUnconditionallyVisible().
Also invert the sense of the return value. As pointed out by the FIXME that this change resolves, isHidden() wasn't a very accurate name for this function. I haven't yet changed any of the strings that are output in ASTDumper.cpp / JSONNodeDumper.cpp / TextNodeDumper.cpp in response to whether isHidden() is set because a) I'm not sure whether it's actually desired to change these strings (would appreciate feedback on this), and b) In any case, I'd like to get this pure rename out of the way first, without any changes to tests. Changing the strings that are output in the various ...Dumper.cpp files will require changes to quite a few tests, and I'd like to make those in a separate change. Differential Revision: https://reviews.llvm.org/D81392 Reviewed By: rsmith
This commit is contained in:
@@ -780,18 +780,19 @@ public:
|
||||
/// all declarations in a global module fragment are unowned.
|
||||
Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
|
||||
|
||||
/// Determine whether this declaration might be hidden from name
|
||||
/// lookup. Note that the declaration might be visible even if this returns
|
||||
/// \c false, if the owning module is visible within the query context.
|
||||
// FIXME: Rename this to make it clearer what it does.
|
||||
bool isHidden() const {
|
||||
return (int)getModuleOwnershipKind() > (int)ModuleOwnershipKind::Visible;
|
||||
/// Determine whether this declaration is definitely visible to name lookup,
|
||||
/// independent of whether the owning module is visible.
|
||||
/// Note: The declaration may be visible even if this returns \c false if the
|
||||
/// owning module is visible within the query context. This is a low-level
|
||||
/// helper function; most code should be calling Sema::isVisible() instead.
|
||||
bool isUnconditionallyVisible() const {
|
||||
return (int)getModuleOwnershipKind() <= (int)ModuleOwnershipKind::Visible;
|
||||
}
|
||||
|
||||
/// Set that this declaration is globally visible, even if it came from a
|
||||
/// module that is not visible.
|
||||
void setVisibleDespiteOwningModule() {
|
||||
if (isHidden())
|
||||
if (!isUnconditionallyVisible())
|
||||
setModuleOwnershipKind(ModuleOwnershipKind::Visible);
|
||||
}
|
||||
|
||||
|
||||
@@ -2883,11 +2883,11 @@ ObjCInterfaceDecl::filtered_category_iterator<Filter>::operator++() {
|
||||
}
|
||||
|
||||
inline bool ObjCInterfaceDecl::isVisibleCategory(ObjCCategoryDecl *Cat) {
|
||||
return !Cat->isHidden();
|
||||
return Cat->isUnconditionallyVisible();
|
||||
}
|
||||
|
||||
inline bool ObjCInterfaceDecl::isVisibleExtension(ObjCCategoryDecl *Cat) {
|
||||
return Cat->IsClassExtension() && !Cat->isHidden();
|
||||
return Cat->IsClassExtension() && Cat->isUnconditionallyVisible();
|
||||
}
|
||||
|
||||
inline bool ObjCInterfaceDecl::isKnownExtension(ObjCCategoryDecl *Cat) {
|
||||
|
||||
@@ -348,7 +348,7 @@ public:
|
||||
/// program.
|
||||
static bool isVisible(Sema &SemaRef, NamedDecl *D) {
|
||||
// If this declaration is not hidden, it's visible.
|
||||
if (!D->isHidden())
|
||||
if (D->isUnconditionallyVisible())
|
||||
return true;
|
||||
|
||||
// During template instantiation, we can refer to hidden declarations, if
|
||||
|
||||
@@ -1862,7 +1862,7 @@ public:
|
||||
|
||||
/// Determine whether a declaration is visible to name lookup.
|
||||
bool isVisible(const NamedDecl *D) {
|
||||
return !D->isHidden() || isVisibleSlow(D);
|
||||
return D->isUnconditionallyVisible() || isVisibleSlow(D);
|
||||
}
|
||||
|
||||
/// Determine whether any declaration of an entity is visible.
|
||||
|
||||
@@ -54,7 +54,7 @@ void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
|
||||
NodeDumper.AddChild([=] {
|
||||
NodeDumper.dumpBareDeclRef(*RI);
|
||||
|
||||
if ((*RI)->isHidden())
|
||||
if (!(*RI)->isUnconditionallyVisible())
|
||||
OS << " hidden";
|
||||
|
||||
// If requested, dump the redecl chain for this lookup.
|
||||
|
||||
@@ -94,7 +94,7 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance,
|
||||
// methods there.
|
||||
if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
|
||||
if (const ObjCProtocolDecl *Def = Proto->getDefinition())
|
||||
if (Def->isHidden() && !AllowHidden)
|
||||
if (!Def->isUnconditionallyVisible() && !AllowHidden)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC,
|
||||
// property.
|
||||
if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(DC)) {
|
||||
if (const ObjCProtocolDecl *Def = Proto->getDefinition())
|
||||
if (Def->isHidden())
|
||||
if (!Def->isUnconditionallyVisible())
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ ObjCPropertyDecl *ObjCContainerDecl::FindPropertyDeclaration(
|
||||
// Don't find properties within hidden protocol definitions.
|
||||
if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
|
||||
if (const ObjCProtocolDecl *Def = Proto->getDefinition())
|
||||
if (Def->isHidden())
|
||||
if (!Def->isUnconditionallyVisible())
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1919,7 +1919,7 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
|
||||
// If there is no definition or the definition is hidden, we don't find
|
||||
// anything.
|
||||
const ObjCProtocolDecl *Def = getDefinition();
|
||||
if (!Def || Def->isHidden())
|
||||
if (!Def || !Def->isUnconditionallyVisible())
|
||||
return nullptr;
|
||||
|
||||
if ((MethodDecl = getMethod(Sel, isInstance)))
|
||||
|
||||
@@ -111,7 +111,7 @@ void JSONNodeDumper::Visit(const Decl *D) {
|
||||
JOS.attribute("isReferenced", true);
|
||||
|
||||
if (const auto *ND = dyn_cast<NamedDecl>(D))
|
||||
attributeOnlyIfTrue("isHidden", ND->isHidden());
|
||||
attributeOnlyIfTrue("isHidden", !ND->isUnconditionallyVisible());
|
||||
|
||||
if (D->getLexicalDeclContext() != D->getDeclContext()) {
|
||||
// Because of multiple inheritance, a DeclContext pointer does not produce
|
||||
|
||||
@@ -252,7 +252,7 @@ void TextNodeDumper::Visit(const Decl *D) {
|
||||
const_cast<NamedDecl *>(ND)))
|
||||
AddChild([=] { OS << "also in " << M->getFullModuleName(); });
|
||||
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
|
||||
if (ND->isHidden())
|
||||
if (!ND->isUnconditionallyVisible())
|
||||
OS << " hidden";
|
||||
if (D->isImplicit())
|
||||
OS << " implicit";
|
||||
|
||||
@@ -1272,7 +1272,8 @@ Decl *Sema::ActOnStartProtocolInterface(
|
||||
|
||||
static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl,
|
||||
ObjCProtocolDecl *&UndefinedProtocol) {
|
||||
if (!PDecl->hasDefinition() || PDecl->getDefinition()->isHidden()) {
|
||||
if (!PDecl->hasDefinition() ||
|
||||
!PDecl->getDefinition()->isUnconditionallyVisible()) {
|
||||
UndefinedProtocol = PDecl;
|
||||
return true;
|
||||
}
|
||||
@@ -3235,7 +3236,7 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *left,
|
||||
return false;
|
||||
|
||||
// If either is hidden, it is not considered to match.
|
||||
if (left->isHidden() || right->isHidden())
|
||||
if (!left->isUnconditionallyVisible() || !right->isUnconditionallyVisible())
|
||||
return false;
|
||||
|
||||
if (left->isDirectMethod() != right->isDirectMethod())
|
||||
@@ -3494,7 +3495,7 @@ bool Sema::CollectMultipleMethodsInGlobalPool(
|
||||
ObjCMethodList &MethList = InstanceFirst ? Pos->second.first :
|
||||
Pos->second.second;
|
||||
for (ObjCMethodList *M = &MethList; M; M = M->getNext())
|
||||
if (M->getMethod() && !M->getMethod()->isHidden()) {
|
||||
if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
|
||||
if (FilterMethodsByTypeBound(M->getMethod(), TypeBound))
|
||||
Methods.push_back(M->getMethod());
|
||||
}
|
||||
@@ -3510,7 +3511,7 @@ bool Sema::CollectMultipleMethodsInGlobalPool(
|
||||
ObjCMethodList &MethList2 = InstanceFirst ? Pos->second.second :
|
||||
Pos->second.first;
|
||||
for (ObjCMethodList *M = &MethList2; M; M = M->getNext())
|
||||
if (M->getMethod() && !M->getMethod()->isHidden()) {
|
||||
if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
|
||||
if (FilterMethodsByTypeBound(M->getMethod(), TypeBound))
|
||||
Methods.push_back(M->getMethod());
|
||||
}
|
||||
@@ -3557,7 +3558,7 @@ ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R,
|
||||
ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
|
||||
SmallVector<ObjCMethodDecl *, 4> Methods;
|
||||
for (ObjCMethodList *M = &MethList; M; M = M->getNext()) {
|
||||
if (M->getMethod() && !M->getMethod()->isHidden())
|
||||
if (M->getMethod() && M->getMethod()->isUnconditionallyVisible())
|
||||
return M->getMethod();
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -1710,7 +1710,8 @@ bool Sema::hasVisibleMemberSpecialization(
|
||||
/// path (by instantiating a template, you allow it to see the declarations that
|
||||
/// your module can see, including those later on in your module).
|
||||
bool LookupResult::isVisibleSlow(Sema &SemaRef, NamedDecl *D) {
|
||||
assert(D->isHidden() && "should not call this: not in slow case");
|
||||
assert(!D->isUnconditionallyVisible() &&
|
||||
"should not call this: not in slow case");
|
||||
|
||||
Module *DeclModule = SemaRef.getOwningModule(D);
|
||||
assert(DeclModule && "hidden decl has no owning module");
|
||||
|
||||
@@ -4038,7 +4038,7 @@ static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
|
||||
void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner) {
|
||||
assert(Owner->NameVisibility != Module::Hidden && "nothing to make visible?");
|
||||
for (Decl *D : Names) {
|
||||
bool wasHidden = D->isHidden();
|
||||
bool wasHidden = !D->isUnconditionallyVisible();
|
||||
D->setVisibleDespiteOwningModule();
|
||||
|
||||
if (wasHidden && SemaObj) {
|
||||
@@ -4100,9 +4100,9 @@ void ASTReader::makeModuleVisible(Module *Mod,
|
||||
/// visible.
|
||||
void ASTReader::mergeDefinitionVisibility(NamedDecl *Def,
|
||||
NamedDecl *MergedDef) {
|
||||
if (Def->isHidden()) {
|
||||
if (!Def->isUnconditionallyVisible()) {
|
||||
// If MergedDef is visible or becomes visible, make the definition visible.
|
||||
if (!MergedDef->isHidden())
|
||||
if (MergedDef->isUnconditionallyVisible())
|
||||
Def->setVisibleDespiteOwningModule();
|
||||
else {
|
||||
getContext().mergeDefinitionIntoModule(
|
||||
|
||||
@@ -6057,7 +6057,7 @@ void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
|
||||
void ASTWriter::RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {
|
||||
if (Chain && Chain->isProcessingUpdateRecords()) return;
|
||||
assert(!WritingAST && "Already writing the AST!");
|
||||
assert(D->isHidden() && "expected a hidden declaration");
|
||||
assert(!D->isUnconditionallyVisible() && "expected a hidden declaration");
|
||||
DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_EXPORTED, M));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user