pygccxml icon indicating copy to clipboard operation
pygccxml copied to clipboard

Problem parsing castxml output of template function default argument of template type

Open lordylike opened this issue 7 years ago • 2 comments

I've recently started migrating from gccxml to castxml and have encountered the aforementioned problem. I could narrow the problem down to a minimum example that still fails:

template<typename Type>
class TemplateClass
{
public:
	void func(Type val = (Type)0.0)
 	{
	}
};
template class TemplateClass<float>;

Called with following cmd line arguments: -std=c++14 -c -x c++ --castxml-cc-msvc "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe" --castxml-gccxml -o "test.xml" "test.h"

Produces an xml with following argument tag:

<Method id="_8" name="func" returns="_14" context="_5" access="public" location="f1:7" file="f1" line="7" inline="1" mangled="?func@?$TemplateClass@MN@@QAEXMN@Z" attributes="__thiscall__">
    <Argument name="val" type="_15" location="f1:7" file="f1" line="7" default="(type-parameter-0-0)0."/>
</Method>

The information referring to the (Type)0.0 default argument given can be found within the (type-parameter-0-0) information found in the Argument tag default coupled with the Class referenced in the Method's context information, which states:

<Class id="_5" name="TemplateClass&lt;float&gt;" context="_1" location="f1:13" file="f1" line="13" members="_8 _9 _10 _11 _12" size="8" align="8"/>

From these two places, I would expect gccxml to figure out that the default argument should be written as (float)0.. Instead it parses this to (type-parameter-0-0)0..

lordylike avatar Jun 09 '17 19:06 lordylike