This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Getting a virtual functions VT lookup index
- From: Brendon Costa <bcosta at avdat dot com dot au>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 17 Oct 2006 17:29:31 +1000
- Subject: Getting a virtual functions VT lookup index
Hi all,
How can I find a FUNCTION_DECL node from a CALL_EXPR node for virtual
function calls?
Note: I am not after the node for the function that will be executed
at runtime as I know this is not possible to determine in most
situations.
Thanks for any help in advance,
Brendon.
-----------------------
I have tried the following:
When I encounter a CALL_EXPR for a virtual function call, I can get
the index for the virtual function table from the OBJ_TYPE_REF object
operand: 2 is an INTEGER_CST that seems to have a different index for
the various virtual functions.
However I need to find the FUNCTION_DECL node that is associated with
a particular type with the given virtual function table index.
For example if I have a index value of: 1 that I have obtained from
the OBJ_TYPE_REF node operand 2 I can also get the METHOD_TYPE node
and thus get the RECORD_TYPE node for the object.
How can I find the FUNCTION_DECL node given the virtual table index of
the function and the classes RECORD_TYPE node?
* I have tried using class.c: get_vcall_index() but it seems to return
negative integers.
* I have also looked in the TYPE_BINFO with the BINFO_VIRTUALS for the
BV_CALL_INDEX but that is NULL.
* I have also tried using CLASSTYPE_VCALL_INDICES and all these have
failed to give me a value that seems correct.