How to manipulate GCC Data Structures

Code tree representation

Gcc maintains a single-node representation for many code components. For example the same identifier name is always represented by the same node. This is done through the tree interfaces (implemented) in tree.c. To get the unique node for an identifier, use tree id = get_identifier (name), where name is a character string.

If you want to print out the string representation of the node type, you can use the following trick due to TongxinBai. As an example cute code trick in Gcc, while the tree types are defined in enum tree_code in tree.h, the actual definition is not in tree.h but in tree.def, which includes a list of all node types and their (string) symbols. Looking at the code you'll quickly see how the trick works, and borrowing it you can easily construct an array of type strings (in your program file) as follows: