davidmalcolm/gcc-python-plugin — pull request #25 by bloff (2014-10-18 19:06:33+00:00)
Title: Added ability to get the result of DECL_ORIGINAL_TYPE

TypeDecl now has a "original_type" attribute which evaluates to the
outcome of DECL_ORIGINAL_TYPE(TYPE_NAME(t)).

I needed this because when a statement such as:

typedef struct foo bar;

appeared, there was no way to know what foo was, since the TypeDecl instance's "type" attribute was the type for bar, and not for foo. After reading a bit about gcc plugin internals, I realized I was supposed to get foo from bar via the macro DECL_ORIGINAL_TYPE (which follows the typedef chain upwards). So I added an "original_type" attribute to the TypeDecl instances, by immitating what was done with the "pointer" attribute.