aaron.ballman added a comment.

In D141472#4092745 <https://reviews.llvm.org/D141472#4092745>, @tbaeder wrote:

> In D141472#4091662 <https://reviews.llvm.org/D141472#4091662>, @aaron.ballman 
> wrote:
>
>> Design question -- do you anticipate this class handling *all* function 
>> pointers, including pointer to member functions that might be virtual: 
>> https://godbolt.org/z/hT8fMY37n
>
> I had to make a few adjustments but I have that example working locally now, 
> of course no idea if that would work generally. Do you see any problem with 
> the proposed `FunctionPointer` class?
>
> According to https://clang.llvm.org/docs/ConstantInterpreter.html#pointers, 
> there was a `MemberPointer` class that sounds related to this, but I don't 
> know more about it. I guess, since you made `func()` virtual, that matters 
> and becomes a bytecode-runtime decision instead of being known at 
> compile-time, which seems to be the case in your example?

Member pointers (for functions or for data) are weird in that they're not the 
typical pointer width. They're actually a pointer and between one-to-three 
other fields in a trenchcoat, depending on the circumstances. You generally 
need the function pointer, but you also may need various offsets (to this, to 
the vtable, etc). There's some more information about how it's done in MSVC 
(which is different from Itanium ABI, but we can do what we want for the 
constant expression interpreter): https://rants.vastheman.com/2021/09/21/msvc/

I don't think there's a problem with `FunctionPointer` per se, I'm more 
wondering are you planning to also add a `MemberPointer` type or are you 
planning to reuse `FunctionPointer` to handle function members (and presumably 
something else for data members)?

As for virtual functions in general, the standard has rules: 
http://eel.is/c++draft/expr.const#5.6 and http://eel.is/c++draft/expr.const#7


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

https://reviews.llvm.org/D141472

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to