[PATCH] D81732: [clang] Replace Decl::isUnconditionallyVisible() with Sema::isVisible()

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 12 05:22:15 PDT 2020


mboehme created this revision.
mboehme added a reviewer: rsmith.
mboehme added a project: clang.
Herald added a subscriber: cfe-commits.

For context, see
https://bugs.llvm.org/show_bug.cgi?id=46248

This handles only the easy cases in Sema/SemaDeclObjC.cpp. The cases in AST/DeclObjC.{h,cpp} will require much more work, but there's no reason not to get the easy work out of the way now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81732

Files:
  clang/lib/Sema/SemaDeclObjC.cpp


Index: clang/lib/Sema/SemaDeclObjC.cpp
===================================================================
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -1270,16 +1270,16 @@
   return ActOnObjCContainerStartDefinition(PDecl);
 }
 
-static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl,
-                                          ObjCProtocolDecl *&UndefinedProtocol) {
-  if (!PDecl->hasDefinition() ||
-      !PDecl->getDefinition()->isUnconditionallyVisible()) {
+static bool
+NestedProtocolHasNoDefinition(Sema &SemaRef, ObjCProtocolDecl *PDecl,
+                              ObjCProtocolDecl *&UndefinedProtocol) {
+  if (!PDecl->hasDefinition() || !SemaRef.isVisible(PDecl->getDefinition())) {
     UndefinedProtocol = PDecl;
     return true;
   }
 
   for (auto *PI : PDecl->protocols())
-    if (NestedProtocolHasNoDefinition(PI, UndefinedProtocol)) {
+    if (NestedProtocolHasNoDefinition(SemaRef, PI, UndefinedProtocol)) {
       UndefinedProtocol = PI;
       return true;
     }
@@ -1325,7 +1325,7 @@
     ObjCProtocolDecl *UndefinedProtocol;
 
     if (WarnOnDeclarations &&
-        NestedProtocolHasNoDefinition(PDecl, UndefinedProtocol)) {
+        NestedProtocolHasNoDefinition(*this, PDecl, UndefinedProtocol)) {
       Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
       Diag(UndefinedProtocol->getLocation(), diag::note_protocol_decl_undefined)
         << UndefinedProtocol;
@@ -1461,7 +1461,7 @@
       // FIXME: Recover nicely in the hidden case.
       ObjCProtocolDecl *forwardDecl = nullptr;
       if (warnOnIncompleteProtocols &&
-          NestedProtocolHasNoDefinition(proto, forwardDecl)) {
+          NestedProtocolHasNoDefinition(*this, proto, forwardDecl)) {
         Diag(identifierLocs[i], diag::warn_undef_protocolref)
           << proto->getDeclName();
         Diag(forwardDecl->getLocation(), diag::note_protocol_decl_undefined)
@@ -3236,7 +3236,7 @@
     return false;
 
   // If either is hidden, it is not considered to match.
-  if (!left->isUnconditionallyVisible() || !right->isUnconditionallyVisible())
+  if (!isVisible(left) || !isVisible(right))
     return false;
 
   if (left->isDirectMethod() != right->isDirectMethod())
@@ -3495,7 +3495,7 @@
   ObjCMethodList &MethList = InstanceFirst ? Pos->second.first :
                              Pos->second.second;
   for (ObjCMethodList *M = &MethList; M; M = M->getNext())
-    if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
+    if (M->getMethod() && isVisible(M->getMethod())) {
       if (FilterMethodsByTypeBound(M->getMethod(), TypeBound))
         Methods.push_back(M->getMethod());
     }
@@ -3511,7 +3511,7 @@
   ObjCMethodList &MethList2 = InstanceFirst ? Pos->second.second :
                               Pos->second.first;
   for (ObjCMethodList *M = &MethList2; M; M = M->getNext())
-    if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
+    if (M->getMethod() && isVisible(M->getMethod())) {
       if (FilterMethodsByTypeBound(M->getMethod(), TypeBound))
         Methods.push_back(M->getMethod());
     }
@@ -3558,7 +3558,7 @@
   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()->isUnconditionallyVisible())
+    if (M->getMethod() && isVisible(M->getMethod()))
       return M->getMethod();
   }
   return nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81732.270366.patch
Type: text/x-patch
Size: 3514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200612/d17f5a11/attachment.bin>


More information about the cfe-commits mailing list