This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions
- From: Ian Lance Taylor <iant at google dot com>
- To: Mario Miller <mario-miller at gmx dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 15 Aug 2012 08:43:36 -0700
- Subject: Re: GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions
- References: <20120815111549.153750@gmx.net>
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