GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions
Ian Lance Taylor
iant@google.com
Thu Aug 16 16:32:00 GMT 2012
On Thu, Aug 16, 2012 at 6:28 AM, Mario Miller <mario-miller@gmx.de> wrote:
>
> -------- Original-Nachricht --------
>> Datum: Wed, 15 Aug 2012 08:43:36 -0700
>> Von: Ian Lance Taylor <iant@google.com>
>> An: Mario Miller <mario-miller@gmx.de>
>> CC: gcc-help@gcc.gnu.org
>> Betreff: Re: GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions
>
>> 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
>
> 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.
Then I don't know. Sorry. What happens when you pass the tree to debug_tree?
Ian
More information about the Gcc-help
mailing list