From 0a384496099569c2a675a94c5af06ad83cccb247 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 24 Dec 2018 14:08:31 +0100 Subject: Changed implementation, added test case --- src/defargs.l | 35 ++++++++--- testing/075/struct_foo.xml | 148 +++++++++++++++++++++++++++++++++++++++++++++ testing/075_argmatch.cpp | 30 +++++++++ 3 files changed, 203 insertions(+), 10 deletions(-) create mode 100644 testing/075/struct_foo.xml create mode 100644 testing/075_argmatch.cpp diff --git a/src/defargs.l b/src/defargs.l index 86e2529..d726fa9 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -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 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; } %} @@ -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); } diff --git a/testing/075/struct_foo.xml b/testing/075/struct_foo.xml new file mode 100644 index 0000000..eca791b --- /dev/null +++ b/testing/075/struct_foo.xml @@ -0,0 +1,148 @@ + + + + Foo + + + void + void Foo::foo + (float value) + foo + + float + value + + + Float. + + + + + + + + + void + void Foo::foo + (unsigned value) + foo + + unsigned + value + + + Unsigned int. + + + + + + + + + void + void Foo::foo + (unsigned long) + foo + + unsigned long + + + Unnamed unsigned long. + + + + + + + + + void + void Foo::foo + (signed long) + foo + + signed long + + + Unnamed signed long. + + + + + + + + + void + void Foo::foo + (const struct Foo) + foo + + const struct Foo + + + Unnamed struct foo. + + + + + + + + + void + void Foo::foo + (const char *const, const double param2) + foo + + const char * const + + + const double + param2 + + + Unnamed const pointer. + + + + + + + + + + Foo. + + + + + + + Foo + foo + + + Foo + foo + + + Foo + foo + + + Foo + foo + + + Foo + foo + + + Foo + foo + + + + diff --git a/testing/075_argmatch.cpp b/testing/075_argmatch.cpp new file mode 100644 index 0000000..439cdca --- /dev/null +++ b/testing/075_argmatch.cpp @@ -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); + -- cgit v0.12