This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to get attual method in GCC AST
- From: Kien Nguyen Trung <kiennt at applistar dot com>
- To: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 3 Aug 2010 09:20:56 +0700
- Subject: How to get attual method in GCC AST
I am work on a project related with GCC AST.
In my project, i write a plugin for GCC. This plugin read a AST from a
source code, a covert this source code to another language.
Currently i have a problem with GCC AST. In particular, i cannot
retrieve all information about CALL_EXPR.
I read GCC internal, and i have known about structure of CALL_EXPR node in GCC.
But when i have a source code
class A{
public:
?? ?virtual void read();
};
class B : A {
public:
?? ?int a;
?? ?void read() {}
};
class D {
public:
?? ?void test() {
?? ? ? ?B *b;
?? ? ? ?b->read();
?? ?}
};
int main(int argc, char** argv) {
?? ?D d;
?? ?d.test();
}
This is AST of method test in class D i got:
bind_expr (test.cpp:21-18)
?? ?statement_list
?? ? ?decl_expr (test.cpp:20-12)
?? ? ? ?var_decl : b (B *) (test.cpp :20)
?? ? ?cleanup_point_expr (test.cpp:21-18)
?? ? ? ?expr_stmt (test.cpp:21-18)
?? ? ? ? ?call_expr (test.cpp:21-17)
?? ? ? ? ? ?obj_type_ref
?? ? ? ? ? ? ?indirect_ref (test.cpp:21-17)
?? ? ? ? ? ? ? ?non_lvalue_expr (test.cpp:21-17)
?? ? ? ? ? ? ? ? ?component_ref
?? ? ? ? ? ? ? ? ? ?component_ref
?? ? ? ? ? ? ? ? ? ? ?indirect_ref
?? ? ? ? ? ? ? ? ? ? ? ?non_lvalue_expr
?? ? ? ? ? ? ? ? ? ? ? ? ?var_decl : b (B *) (test.cpp :20)
?? ? ? ? ? ? ? ? ? ? ?field_decl : internal hidden (unknown type) (test.cpp :9)
?? ? ? ? ? ? ? ? ? ?field_decl : _vptr.A (int * *) (test.cpp :4)
?? ? ? ? ? ? ?non_lvalue_expr
?? ? ? ? ? ? ? ?var_decl : b (B *) (test.cpp :20)
?? ? ? ? ? ? ?integer_cst 0
?? ? ? ? ? ?non_lvalue_expr
?? ? ? ? ? ? ?var_decl : b (B *) (test.cpp :20)
The problem is method read() of class B is get from a virtual method
of based class A. And i cannot get the real name of ?this method.
Do you have any ideal to help me. Thansk