Traversing trees in a plugin...
Ian Lance Taylor
iant@google.com
Mon Jun 4 05:40:00 GMT 2012
Brett Foster <fosterb@edgeandvertex.org> writes:
> 1) How to marking a node as visited by my algorithm (without screwing
> up the compiler!)
Use a pointer_set.
> 2) How to associate additional data (perhaps a pointer to something
> else) to a node (like a unique identifier, or a pointer to a data
> structure).
Use a pointer_map.
> b) However with types (especially those that are anonymous) I find it
> challenging to do so. I assign such a node an anonymous identifier or
> try to assign a general data type (i.e. integer) when the type is
> internal.
With types, use TYPE_CANONICAL to get the type that you should add to
the pointer_set or pointer_map. I admit it gets more complicated if
TYPE_CANONICAL is not appropriate for your plugin, e.g., if you need to
distinguish different typedefs for the same type.
> 2) Can memory addresses be used to uniquely identify nodes? I believe
> this may be the case for identifier nodes.
Yes.
Ian
More information about the Gcc
mailing list