This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to access the virtual table?



I am trying to access the virtual table.
My pass is hooked after pass_ipa_pta.

Consider Class A which contains virtual function.
An object created as :
    A a;
is translated in GIMPLE as
    struct A a;

From variable "a" we can get its type which is "struct A".
I tried to see how the dump_vtable function access the table.

To access the virtual table for class A, Below is the code which I tried.

    tree t = TREE_TYPE (a);
    tree binfo = TYPE_BINFO (t);
    tree vtab = BINFO_VTABLE (binfo);

FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (DECL_INITIAL (vtab)), ix, value)

Using the above iterator, entries of the virtual table should be accessible.
However, I am not able to do so.

Kindly inform me the way to access the virtual table.
Also how to fetch the functions from that virtual table?

Regards,
Swati


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]