[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 6 11:03:23 PST 2025
================
@@ -2222,6 +2222,96 @@ class CGObjCObjFW: public CGObjCGNU {
return ClassSymbol;
}
+ void GenerateDirectMethodPrologue(
+ CodeGenFunction &CGF, llvm::Function *Fn, const ObjCMethodDecl *OMD,
+ const ObjCContainerDecl *CD) override {
+ auto &Builder = CGF.Builder;
+ bool ReceiverCanBeNull = true;
+ auto selfAddr = CGF.GetAddrOfLocalVar(OMD->getSelfDecl());
+ auto selfValue = Builder.CreateLoad(selfAddr);
+
+ // Generate:
+ //
+ // /* for class methods only to force class lazy initialization */
+ // self = [self self];
+ //
+ // /* unless the receiver is never NULL */
+ // if (self == nil) {
+ // return (ReturnType){ };
+ // }
+ //
+ // _cmd = @selector(...)
+ // ...
+
+ if (OMD->isClassMethod()) {
+ const ObjCInterfaceDecl *OID = cast<ObjCInterfaceDecl>(CD);
+ assert(
+ OID &&
+ "GenerateDirectMethod() should be called with the Class Interface");
----------------
rjmccall wrote:
Heh, alright.
https://github.com/llvm/llvm-project/pull/126382
More information about the cfe-commits
mailing list