================
@@ -415,11 +417,87 @@ bool CGObjCRuntime::canMessageReceiverBeNull(
 
 bool CGObjCRuntime::canClassObjectBeUnrealized(
     const ObjCInterfaceDecl *CalleeClassDecl, CodeGenFunction &CGF) const {
-  // TODO
+  if (!CalleeClassDecl || isWeakLinkedClass(CalleeClassDecl))
+    return true;
+
+  // Heuristic 1: +load method on this class or any subclass
+  // If the class or any of its subclasses has a +load method, it's realized
+  // when the binary is loaded. We cache this information to avoid repeatedly
+  // scanning the translation unit.
+  if (getOrPopulateRealizedClasses().contains(CalleeClassDecl))
+    return false;
+
+  // Heuristic 2: using Self / Super
+  // If we're currently executing a method of ClassDecl (or a subclass),
----------------
ojhunt wrote:

Maybe "If we're inside the body of method declared on CalleeClassDecl or a 
subclass, CalleeClassDecl must have been realized"?

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

Reply via email to