Boris Kolpackov <bo...@codesynthesis.com> writes: > I am trying to figure out how to get a typedef hierarchy from the C/C++ > tree in GCC. Consider the following declarations: > > struct s {}; > > typedef s s_t; > typedef s_t my_s_t; > > my_s_t x; > > Giveb 'x' VAR_DECL I can have this traversal using TYPE_MAIN_VARIANT(): > > x -> my_s_t -> s; > > What I am trying to achieve is this: > > x -> my_s_t -> s_t -> s > > I looked at TYPE_NEXT_VARIANT(), but this is a list while what I need > is a tree (hierarchy).
But there is no heirarchy in your example. There is only a list. > Some background on why I need this: I would like to determine if a > member of a class is size_t so that I can always map it to a 64-bit > integer in another system (RDBMS). In other words: > > struct s > { > unsigned int i; // -> 32-bit int > size_t s; // -> 64-bit int > } > > Even though size_t might be typedef'ed as unsigned int. In the above > example I can do it. However, adding a level or indirections causes > problems: > > typedef size_t my_size; > > struct s > { > my_size s; // TYPE_MAIN_VARIANT(my_size) == unsigned int > } > > Any ideas will be much appreciated. As far as I know this is not possible. A typedef name is just an alias for the underlying type. When you typedef T as TNAME, where T is itself a typedef, GCC records that TNAME is a name for the underlying type of T. It does not record an equivalence of T and TNAME. The C/C++ language do not require GCC to keep track of this information, and it's simpler for the frontend to just maintain a list. Ian