This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Traversing typedef hierarchy in C/C++ tree
- From: Boris Kolpackov <boris at codesynthesis dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 20 Apr 2011 07:37:13 +0000 (UTC)
- Subject: Traversing typedef hierarchy in C/C++ tree
Hi,
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).
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.
Boris