[clang] [Clang] Resolve FIXME: Use class method when receiver is reference to class (PR #85316)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 14:35:36 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: AtariDreams (AtariDreams)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/85316.diff


1 Files Affected:

- (modified) clang/lib/Analysis/RetainSummaryManager.cpp (+16-2) 


``````````diff
diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp
index 8d279d969b613e..ffe9ab639cc94f 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -1139,12 +1139,26 @@ 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.
   // id x = [NSObject class];
   // [x performSelector:... withObject:... afterDelay:...];
   Selector S = ME->getSelector();
   const ObjCMethodDecl *Method = ME->getMethodDecl();
+
+  if (!Method) {
+    if (ReceiverClass) {
+      if (ReceiverType->isObjCClassType() ||
+          ReceiverType->isQualifiedClassType()) {
+        // 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);
+      }
+    }
+  }
+
   if (!Method && ReceiverClass)
     Method = ReceiverClass->getInstanceMethod(S);
 

``````````

</details>


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


More information about the cfe-commits mailing list