[GCC-XML] C++ Function Definitions

Sandeep Kakarlapudi sandeep.iitkgp at gmail.com
Mon Apr 30 12:59:59 EDT 2007


I want to insert some code at the beginning of every C++ function body
through a tool. Although GCC-XML is aimed at extracting the
declarations, it looks like it provides the required information which
is the file and start line of the function body. When I compile a
source file S containing function definitions and which includes a
header file H containing function declarations, GCC-XML produces an
XML dump where the function's file and line attributes are set to
point to the function definition in S (if present) instead of the
declaration in H.  For all functions without any definitions in S but
having declarations in H the XML data points to the declaration as
expected.

Can I rely on the fact that definitions are preferred over
declarations as far as the source location attributes are concerned?

If anyone knows of a tool that can add code to C++ function prologues
in source files, please let me know - I'm looking for something more
robust than simple regular expression based solutions.

Thanks!
Sandeep

------------------------
Sandeep Kakarlapudi
http://sandeep.iitkgp.googlepages.com/projects



More information about the gccxml mailing list