Jaroslav Sýkora wrote:
Hello, I am working on a research project in which I want to export a whole syntax/semantic tree of a c++ program from the compiler. My current solution is to use the -fdump-tree-all option and take the *.t00.tu files (translation unit dump). I've hacked the gcc/tree-dump.c so the exported graph is in a machine-readable xml file. This all works quite well in gcc 4.1.0. But I've hit a problem with gcc 4.2 and newer - the dump now doesn't contain any function bodies. Specificaly, in tree-dump.c::dequeue_and_dump() there is case FUNCTION_DECL: ... dump_child ("body", DECL_SAVED_TREE (t)); where 't' points to the FUNCTION_DECL tree. It seems that DECL_SAVED_TREE(t) is always NULL in gcc >= 4.2. Practically I am only interested in the gimple cfg and its basic blocks, which I used to get via DECL_STRUCT_FUNCTION(t) - but that doesn't work now either. Working copy of my patches is available for your reference at http://necago.ic.cz/prj/scc/
We support this sort of thing in Mozilla's Treehydra gcc plugin. See http://developer.mozilla.org/en/docs/Treehydra
In addition to cfg you can get much other stuff such as types. Taras