GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions

Ian Lance Taylor iant@google.com
Wed Aug 15 17:32:00 GMT 2012


On Wed, Aug 15, 2012 at 4:15 AM, Mario Miller <mario-miller@gmx.de> wrote:
> I am writing a GCC Plugin which can parse the bodies of functions.
> Parsing member functions of classes works pretty well, but when I
> want to parse a global function and use the DECL_CONTEXT Makro I
> get a TRANSLATION_UNIT_DECL. For member functions I use the
> DECL_SAVED_TREE Makro to parse the function body; this works.
> But when I use this Makro on a global function it returns NULL
> always. My code looks a bit like this:

If you have a TRANSLATION_UNIT_DECL, look in DECL_INITIAL to see the
BLOCK for the namespace that it describes.

Ian



More information about the Gcc-help mailing list