================
@@ -460,29 +460,80 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
     return true;
   }
 
-  bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
-    auto StartLoc = E->getSelectorStartLoc();
-    // Identify the selector and the method declaration
-    if (auto *Method = E->getMethodDecl()) {
-      // Report the method as a used symbol
-      report(StartLoc, Method);
+  /// Determines whether a protocol is already covered by the receiver's type,
+  /// either through adopted protocol qualifiers (e.g. `id<Proto>` or an
+  /// inheriting sub-protocol) or through class conformance on the receiver
+  /// interface (e.g. `MyClass <Proto>`).
+  bool IsProtocolCoveredByReceiver(ObjCProtocolDecl *Proto,
+                                   const ObjCObjectPointerType *ObjCPtr,
+                                   ObjCInterfaceDecl *IFace) {
+    if (ObjCPtr) {
+      ASTContext &Ctx = Proto->getASTContext();
+      for (auto *ReceiverProto : ObjCPtr->quals())
+        if (Ctx.ProtocolCompatibleWithProtocol(Proto, ReceiverProto))
+          return true;
     }
+    return IFace && IFace->ClassImplementsProtocol(Proto, true);
+  }
 
-    // If it's a class message, report the interface/class as used
-    if (E->getReceiverKind() == ObjCMessageExpr::Class) {
-      if (auto *Interface = E->getReceiverInterface()) {
-        report(E->getReceiverRange().getBegin(), Interface);
-      }
-      return true;
-    }
-    if (auto *Interface = E->getReceiverInterface()) {
-      report(StartLoc, Interface, RefType::Implicit);
+  void ReportMemberDecl(SourceLocation Loc, NamedDecl *Member,
----------------
nico wrote:

nit: as in the other PR, the other "report" methods are spelled with a 
lower-case `r` for some Reason, might want to be compatible with that

https://github.com/llvm/llvm-project/pull/216857
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to