https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/85316

>From ea3a9ee76249bd1216bc6aa16dcec6008f12a19b Mon Sep 17 00:00:00 2001
From: Rose <gfunni...@gmail.com>
Date: Thu, 14 Mar 2024 17:34:16 -0400
Subject: [PATCH] Resolve FIXME: Use class method when receiver is reference to
 class

---
 clang/lib/Analysis/RetainSummaryManager.cpp | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp 
b/clang/lib/Analysis/RetainSummaryManager.cpp
index 8d279d969b613e..0a2278643c6e48 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -1139,14 +1139,25 @@ const RetainSummary 
*RetainSummaryManager::getInstanceMethodSummary(
   if (!ReceiverClass)
     ReceiverClass = ME->getReceiverInterface();
 
-  // FIXME: The receiver could be a reference to a class, meaning that
-  //  we should use the class method.
+  // The receiver could be a reference to a class, meaning that
+  // we should use the class method if that happens.
   // id x = [NSObject class];
   // [x performSelector:... withObject:... afterDelay:...];
   Selector S = ME->getSelector();
   const ObjCMethodDecl *Method = ME->getMethodDecl();
-  if (!Method && ReceiverClass)
-    Method = ReceiverClass->getInstanceMethod(S);
+
+  if (!Method) {
+    if (ReceiverClass) {
+      if (ReceiverType->isObjCClassType() ||
+          ReceiverType->isObjCQualifiedClassType()) {
+        // The receiver is a class reference, use the class method.
+        Method = ReceiverClass->getClassMethod(S);
+      } else {
+        // The receiver is an instance reference, use the instance method.
+        Method = ReceiverClass->getInstanceMethod(S);
+      }
+    }
+  }
 
   return getMethodSummary(S, ReceiverClass, Method, ME->getType(),
                           ObjCMethodSummaries);

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to