[PATCH] D66360: Expose constructing a virtual method dispatch through the include/clang/CodeGen APIs.

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 22:22:32 PDT 2019


rjmccall added inline comments.


================
Comment at: include/clang/CodeGen/SwiftCallingConv.h:190
+                                                llvm::FunctionType *type,
+                                                llvm::IRBuilderBase *builder);
+
----------------
This isn't the right header for this.  More thoughts on this point below.

The documentation should describe the expected relationship between `this` and the method.  I imagine that `thisPtr` is expected to already be a pointer to the type which declares the method (i.e. `MD->getParent()`), and in the appropriate address space.

Please name this something like `emitLoadOfCXXVirtualMethod`.

This particular case will probably never need control flow or temporary memory, but I wonder if we should go ahead and introduce an abstraction that bundles the CGM and the builder so that we can teach it to handle those in the future.  If you do, you could just define it in its own header and then make this a method on that.

I think it would be totally reasonable to pull Clang's `Address.h` up to `include/clang/CodeGen` instead of breaking it down here.

Also, this really needs to return a `CGCallee`, which might require pulling that up as well.  The reason why should be clear in a few weeks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66360





More information about the cfe-commits mailing list