Re: Re: Re: GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-------- Original-Nachricht --------
> Datum: Thu, 16 Aug 2012 08:33:39 -0700
> Von: Ian Lance Taylor <iant@xxxxxxxxxx>
> An: Mario Miller <mario-miller@xxxxxx>
> CC: gcc-help@xxxxxxxxxxx
> Betreff: Re: Re: GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions

> On Thu, Aug 16, 2012 at 6:28 AM, Mario Miller <mario-miller@xxxxxx> wrote:
> >
> > -------- 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.
> 
> Then I don't know.  Sorry.  What happens when you pass the tree to
> debug_tree?
> 
> Ian

When I pass the DECL_INITIAL tree to debug_tree it prints out an empty line; so it seems to be NULL.

When I pass the TRANSLATION_UNIT_DECL tree to debug_tree it prints out this:

<translation_unit_decl 0x4051006c D.1 VOID file (null) line 0 col 0
    align 1>

When I pass the FUNCTION_DECL tree to debug_tree it prints out this:

<function_decl 0x410d9e80 generateOutput
    type <function_type 0x405158a0
        type <void_type 0x40508840 void type_6 VOID
            align 8 symtab 0 alias set -1 canonical type 0x40508840
            pointer_to_this <pointer_type 0x405088a0>>
        QI
        size <integer_cst 0x404f10e0 constant 8>
        unit size <integer_cst 0x404f1100 constant 1>
        align 8 symtab 0 alias set -1 canonical type 0x405158a0
        arg-types <tree_list 0x405020d8 value <void_type 0x40508840 void>>
        pointer_to_this <pointer_type 0x4089f900>>
    addressable used public external QI file /usr/doxygen/src/doxygen.h line 146 col 6 align 8 context <translation_unit_decl 0x4051006c D.1>
    full-name "void generateOutput()"
    chain <function_decl 0x410d9e00 parseInput>>

I am parsing the main function of Doxygen in main.cpp.
It calls the global function generateOutput, which is defined and implemented in doxygen.h.
GCC finds this function, as you can see in the debug_tree of the FUNCTION_DECL.
But the TRANSLATION_UNIT_DECL of this function looks like it is 0.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux