[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 30 12:30:18 PDT 2020


rjmccall added inline comments.


================
Comment at: clang/include/clang/CodeGen/CodeGenABITypes.h:148
+                 llvm::function_ref<llvm::Constant *(const ObjCProtocolDecl *)>
+                     createProtocolReference);
 }  // end namespace CodeGen
----------------
I would call this `emitObjCProtocolObject` or something, and maybe say in the comment:

> Get a pointer to a protocol object for the given declaration, emitting it if it hasn't already been emitted in this translation unit.  Note that the ABI for emitting a protocol reference in code (e.g. for a `@protocol` expression) in most runtimes is not as simple as just materializing a pointer to this object.

Can you explain the need for the callback?   Are you expecting to use this for Swift-declared protocols by synthesizing an ObjC protocol declaration for them?  I can see why you'd need a callback in that case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77077/new/

https://reviews.llvm.org/D77077





More information about the cfe-commits mailing list