[GCC-XML] small template handling improvment

Roman Yakovenko roman.yakovenko at gmail.com
Wed May 10 07:46:11 EDT 2006


Hi. Please consider next case:

1.h file:

template< class X >
struct basic_string{};

template< class Ch >
basic_string<Ch> do_smth(){
    return basic_string<Ch>();
}

inline void inst(){
    do_smth<wchar_t>();
}

If you run gccxml on the code, you will see that there is a function
"do_smth" in XML.
But you can not tell whether this function is result of some template
instantiation or not.

A patch, I propose, improves the situation. First of all, every xml element,
that has "mangled" attribute, will have new attribute - "demangled".
This attribute will
contain demangled string. Demangling is done by use of gcc built-in demangler.
( defined in demangle.h )

In our case it will contain next text:

basic_string<wchar_t> do_smth<wchar_t>()

As you can see this text contains additional information:
do_smth<wchar_t>. It is not too
difficult to write some parser that will extract interesting
information from the demangled
string.

I attached the patch with example of code and generated xml to the mail.

Problems with the patch:
1. Adding new text attribute to every node enlarge xml file, and thus
makes slower
   parsing process. As for me, this is not a problem at all. But may
be it is for other
   people. So may be demangled functionality should be optional

2. For some declarations, demangled string does not contains return
type. I don't know
   why. May be some one can take a look on it and fix. Like in
previous case it is not
   a problem for my usage. Cause I am interested only in function name.

Is it possible to apply the patch?

Thanks

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.tar.bz2
Type: application/x-bzip2
Size: 19553 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/gccxml/attachments/20060510/fd16cea8/attachment.bin>


More information about the gccxml mailing list