-------- Original-Nachricht -------- > Datum: Wed, 15 Aug 2012 08:43:36 -0700 > Von: Ian Lance Taylor <iant@xxxxxxxxxx> > An: Mario Miller <mario-miller@xxxxxx> > CC: gcc-help@xxxxxxxxxxx > Betreff: Re: GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions > On Wed, Aug 15, 2012 at 4:15 AM, Mario Miller <mario-miller@xxxxxx> 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 I tried the DECL_INITIAL Makro on the TRANSLATION_UNIT_DECL tree and on the FUNCTION_DECL tree. In both cases it always returns NULL; so i do not get the BLOCK for the namespace.