Skip to content

Commit

Permalink
Changed implementation, added test case
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Dec 24, 2018
1 parent ba8e4ea commit 0a38449
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 10 deletions.
35 changes: 25 additions & 10 deletions src/defargs.l
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,32 @@ static int yyread(char *buf,int max_size)
}

/* bug_520975 */
static bool checkSpecialType(QCString &typ, QCString &nam)
static bool nameIsActuallyPartOfType(QCString &name)
{
if (nam == "unsigned" || nam == "signed" ||
nam == "int" || nam == "long" ||
nam == "volatile" || nam == "const") return TRUE;
QCStringList qsl=QCStringList::split(' ',typ);
for (uint j=0;j<qsl.count();j++)
static bool first=TRUE;
static QDict<void> keywords(17);
if (first) // fill keyword dict first time
{
if (!(qsl[j] == "volatile" || qsl[j] == "const")) return FALSE;
#define DUMMY_ADDR (void*)0x8
keywords.insert("unsigned", DUMMY_ADDR); // foo(... unsigned)
keywords.insert("signed", DUMMY_ADDR); // foo(... signed)
keywords.insert("bool", DUMMY_ADDR); // foo(... bool)
keywords.insert("char", DUMMY_ADDR); // foo(... char)
keywords.insert("int", DUMMY_ADDR); // foo(... int)
keywords.insert("long", DUMMY_ADDR); // foo(... long)
keywords.insert("float", DUMMY_ADDR); // foo(... float)
keywords.insert("double", DUMMY_ADDR); // foo(... double)
keywords.insert("int8_t", DUMMY_ADDR); // foo(... int8_t)
keywords.insert("uint8_t", DUMMY_ADDR); // foo(... uint8_t)
keywords.insert("int16_t", DUMMY_ADDR); // foo(... int16_t)
keywords.insert("uint16_t", DUMMY_ADDR); // foo(... uint16_t)
keywords.insert("int32_t", DUMMY_ADDR); // foo(... int32_t)
keywords.insert("uint32_t", DUMMY_ADDR); // foo(... uint32_t)
keywords.insert("const", DUMMY_ADDR); // foo(... const)
keywords.insert("volatile", DUMMY_ADDR); // foo(... volatile)
first=FALSE;
}
return TRUE;
return keywords.find(name)!=0;
}
%}

Expand Down Expand Up @@ -398,9 +413,9 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
a->type.mid(sv)=="union" ||
a->type.mid(sv)=="class" ||
a->type.mid(sv)=="typename" ||
checkSpecialType(a->type, a->name)
nameIsActuallyPartOfType(a->name)
)
{
{
a->type = a->type + " " + a->name;
a->name.resize(0);
}
Expand Down
148 changes: 148 additions & 0 deletions testing/075/struct_foo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="">
<compounddef id="struct_foo" kind="struct" language="C++" prot="public">
<compoundname>Foo</compoundname>
<sectiondef kind="public-func">
<memberdef kind="function" id="struct_foo_1a4f9767677227174b2a9684b92e36cba7" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>void</type>
<definition>void Foo::foo</definition>
<argsstring>(float value)</argsstring>
<name>foo</name>
<param>
<type>float</type>
<declname>value</declname>
</param>
<briefdescription>
<para>Float. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="075_argmatch.cpp" line="5" column="1" bodyfile="075_argmatch.cpp" bodystart="14" bodyend="14"/>
</memberdef>
<memberdef kind="function" id="struct_foo_1a3b1460a8784e5cc8156899a04df08b94" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>void</type>
<definition>void Foo::foo</definition>
<argsstring>(unsigned value)</argsstring>
<name>foo</name>
<param>
<type>unsigned</type>
<declname>value</declname>
</param>
<briefdescription>
<para>Unsigned int. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="075_argmatch.cpp" line="6" column="1" bodyfile="075_argmatch.cpp" bodystart="17" bodyend="17"/>
</memberdef>
<memberdef kind="function" id="struct_foo_1a87f5be128245c4a16b25500fe6ae2fd1" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>void</type>
<definition>void Foo::foo</definition>
<argsstring>(unsigned long)</argsstring>
<name>foo</name>
<param>
<type>unsigned long</type>
</param>
<briefdescription>
<para>Unnamed unsigned long. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="075_argmatch.cpp" line="7" column="1" bodyfile="075_argmatch.cpp" bodystart="20" bodyend="20"/>
</memberdef>
<memberdef kind="function" id="struct_foo_1adc1cd4494f8a556d5bf6cb78409e3e68" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>void</type>
<definition>void Foo::foo</definition>
<argsstring>(signed long)</argsstring>
<name>foo</name>
<param>
<type>signed long</type>
</param>
<briefdescription>
<para>Unnamed signed long. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="075_argmatch.cpp" line="8" column="1" bodyfile="075_argmatch.cpp" bodystart="23" bodyend="23"/>
</memberdef>
<memberdef kind="function" id="struct_foo_1a0baba36cdd24740c6e39d5641e30a0fe" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>void</type>
<definition>void Foo::foo</definition>
<argsstring>(const struct Foo)</argsstring>
<name>foo</name>
<param>
<type>const struct <ref refid="struct_foo" kindref="compound">Foo</ref></type>
</param>
<briefdescription>
<para>Unnamed struct foo. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="075_argmatch.cpp" line="9" column="1" bodyfile="075_argmatch.cpp" bodystart="26" bodyend="26"/>
</memberdef>
<memberdef kind="function" id="struct_foo_1abeaaeb54ad61db26205c06927968845f" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>void</type>
<definition>void Foo::foo</definition>
<argsstring>(const char *const, const double param2)</argsstring>
<name>foo</name>
<param>
<type>const char * const</type>
</param>
<param>
<type>const double</type>
<declname>param2</declname>
</param>
<briefdescription>
<para>Unnamed const pointer. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="075_argmatch.cpp" line="10" column="1"/>
</memberdef>
</sectiondef>
<briefdescription>
<para><ref refid="struct_foo" kindref="compound">Foo</ref>. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="075_argmatch.cpp" line="4" column="1" bodyfile="075_argmatch.cpp" bodystart="4" bodyend="11"/>
<listofallmembers>
<member refid="struct_foo_1a4f9767677227174b2a9684b92e36cba7" prot="public" virt="non-virtual">
<scope>Foo</scope>
<name>foo</name>
</member>
<member refid="struct_foo_1a3b1460a8784e5cc8156899a04df08b94" prot="public" virt="non-virtual">
<scope>Foo</scope>
<name>foo</name>
</member>
<member refid="struct_foo_1a87f5be128245c4a16b25500fe6ae2fd1" prot="public" virt="non-virtual">
<scope>Foo</scope>
<name>foo</name>
</member>
<member refid="struct_foo_1adc1cd4494f8a556d5bf6cb78409e3e68" prot="public" virt="non-virtual">
<scope>Foo</scope>
<name>foo</name>
</member>
<member refid="struct_foo_1a0baba36cdd24740c6e39d5641e30a0fe" prot="public" virt="non-virtual">
<scope>Foo</scope>
<name>foo</name>
</member>
<member refid="struct_foo_1abeaaeb54ad61db26205c06927968845f" prot="public" virt="non-virtual">
<scope>Foo</scope>
<name>foo</name>
</member>
</listofallmembers>
</compounddef>
</doxygen>
30 changes: 30 additions & 0 deletions testing/075_argmatch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// objective: test argument matching in particular for unnamed types
// check: struct_foo.xml
/** @brief Foo */
struct Foo {
void foo(float value);
void foo(unsigned value);
void foo(unsigned long);
void foo(signed long);
void foo(const struct Foo);
void foo(const char * const, const double param2);
};

/** @brief Float */
void Foo::foo(float) {}

/** @brief Unsigned int */
void Foo::foo(unsigned value) {}

/** @brief Unnamed unsigned long */
void Foo::foo(unsigned long) {}

/** @brief Unnamed signed long */
void Foo::foo(signed long) {}

/** @brief Unnamed struct foo */
void Foo::foo(const struct Foo) {}

/** @brief Unnamed const pointer */
void Foo::foo(const char * const, const double param2);

0 comments on commit 0a38449

Please sign in to comment.