GCC Plugin TRANSLATION_UNIT_DECL - Parsing global functions

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

 



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(TREE_CODE(expr) == FUNCTION_DECL)
{
    tree context = DECL_CONTEXT(expr);
    if(TREE_CODE(context) == TRANSLATION_UNIT_DECL)
    {
        if(DECL_SAVED_TREE(expr))
            traverseExpression(DECL_SAVED_TREE(expr));
        else
            std::cerr << "DECL_SAVED_TREE(expr) is NULL\n";
    }
    else
        /* Traverse member function */
}

The documentation says about TRANSLATION_UNIT_DECL: "A translation
unit.  This is not technically a declaration, since it can't be
looked up, but it's close enough." I don't understand what that
means. Can somebody tell me how I can parse the bodies of global
functions?


[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