Fixed handling of qualifiers in unexposed template parameters
This commit is contained in:
@@ -795,7 +795,10 @@ template_parameter map_type_parameter_to_template_parameter(
|
|||||||
detail::map_type_parameter_to_template_parameter(alias_decl, tp));
|
detail::map_type_parameter_to_template_parameter(alias_decl, tp));
|
||||||
}
|
}
|
||||||
|
|
||||||
return template_parameter::make_argument(tp);
|
std::string arg = tp;
|
||||||
|
if (arg == "_Bool")
|
||||||
|
arg = "bool";
|
||||||
|
return template_parameter::make_argument(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<template_parameter> build_template_parameter(
|
std::optional<template_parameter> build_template_parameter(
|
||||||
@@ -822,14 +825,15 @@ std::optional<template_parameter> build_template_parameter(
|
|||||||
return {};
|
return {};
|
||||||
|
|
||||||
// simple template param without qualifiers
|
// simple template param without qualifiers
|
||||||
if (common::is_type_token(*it) && it_next == end) {
|
if (common::is_type_token(*it) && (it_next == end || *it_next == ")")) {
|
||||||
res = map_type_parameter_to_template_parameter(decl, *it);
|
res = map_type_parameter_to_template_parameter(decl, *it);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// template parameter with qualifier at the end
|
// template parameter with qualifier at the end
|
||||||
else if (common::is_type_token(*it) && common::is_qualifier(*it_next)) {
|
else if (common::is_type_token(*it) && common::is_qualifier(*it_next)) {
|
||||||
res = map_type_parameter_to_template_parameter(decl, *it);
|
res = map_type_parameter_to_template_parameter(decl, *it);
|
||||||
res.set_qualifier(*it_next);
|
param_qualifier += *it_next;
|
||||||
|
res.set_qualifier(param_qualifier);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// method template parameter
|
// method template parameter
|
||||||
@@ -847,7 +851,8 @@ std::optional<template_parameter> build_template_parameter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (it != end && common::is_qualifier(*it)) {
|
if (it != end && common::is_qualifier(*it)) {
|
||||||
res.set_qualifier(*it);
|
param_qualifier += *it;
|
||||||
|
res.set_qualifier(param_qualifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -861,17 +866,18 @@ std::optional<template_parameter> build_template_parameter(
|
|||||||
else if (common::is_type_token(*it) && *it_next == "(") {
|
else if (common::is_type_token(*it) && *it_next == "(") {
|
||||||
res.add_template_param(
|
res.add_template_param(
|
||||||
map_type_parameter_to_template_parameter(decl, *it));
|
map_type_parameter_to_template_parameter(decl, *it));
|
||||||
it_next++;
|
it_next++; // skip '('
|
||||||
res.add_template_param(
|
res.add_template_param(
|
||||||
map_type_parameter_to_template_parameter(decl, *it_next));
|
map_type_parameter_to_template_parameter(decl, *it_next));
|
||||||
|
|
||||||
it = it_next;
|
it = it_next;
|
||||||
it++;
|
it++;
|
||||||
if (*it == "::") {
|
it_next = it;
|
||||||
|
it_next++;
|
||||||
|
|
||||||
|
if (*it == "::" && *it_next == "*") {
|
||||||
res.set_method_template(true);
|
res.set_method_template(true);
|
||||||
it++;
|
std::advance(it, 3);
|
||||||
it++;
|
|
||||||
it++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it != end) {
|
if (it != end) {
|
||||||
@@ -879,6 +885,7 @@ std::optional<template_parameter> build_template_parameter(
|
|||||||
if (*it == "(") {
|
if (*it == "(") {
|
||||||
it++;
|
it++;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
// This will break on more complex args
|
||||||
auto arg_separator = std::find(it, end, ",");
|
auto arg_separator = std::find(it, end, ",");
|
||||||
if (arg_separator == end) {
|
if (arg_separator == end) {
|
||||||
// just one arg
|
// just one arg
|
||||||
@@ -904,7 +911,8 @@ std::optional<template_parameter> build_template_parameter(
|
|||||||
it++;
|
it++;
|
||||||
|
|
||||||
if (it != end && common::is_qualifier(*it)) {
|
if (it != end && common::is_qualifier(*it)) {
|
||||||
res.set_qualifier(*it);
|
param_qualifier += *it;
|
||||||
|
res.set_qualifier(param_qualifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -479,9 +479,8 @@ bool is_identifier_character(char c) { return std::isalnum(c) || c == '_'; }
|
|||||||
|
|
||||||
bool is_identifier(const std::string &t)
|
bool is_identifier(const std::string &t)
|
||||||
{
|
{
|
||||||
return std::isalpha(t.at(0)) &&
|
return std::all_of(t.begin(), t.end(),
|
||||||
std::all_of(t.begin(), t.end(),
|
[](const char c) { return is_identifier_character(c); });
|
||||||
[](const char c) { return is_identifier_character(c); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_keyword(const std::string &t)
|
bool is_keyword(const std::string &t)
|
||||||
|
|||||||
@@ -39,15 +39,15 @@ TEST_CASE("t00062", "[test-case][class]")
|
|||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "T"));
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "U &"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "U &"));
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "U &&"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "U &&"));
|
||||||
// REQUIRE_THAT(puml, IsClassTemplate("A", "U const&"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "U const&"));
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "M C::*"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "M C::*"));
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "M C::*&&"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "M C::*&&"));
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "M (C::*)(Arg)"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "M (C::*)(Arg)"));
|
||||||
// REQUIRE_THAT(puml, IsClassTemplate("A", "int (C::*)(bool)"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "int (C::*)(bool)"));
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "M (C::*)(Arg)&&"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "M (C::*)(Arg)&&"));
|
||||||
// REQUIRE_THAT(puml, IsClassTemplate("A", "int
|
|
||||||
// (C::*)(bool)&&"));
|
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "M (C::*)(Arg1,Arg2,Arg3)"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "M (C::*)(Arg1,Arg2,Arg3)"));
|
||||||
|
REQUIRE_THAT(puml, IsClassTemplate("A", "float (C::*)(int)&&"));
|
||||||
|
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "char[N]"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "char[N]"));
|
||||||
REQUIRE_THAT(puml, IsClassTemplate("A", "char[1000]"));
|
REQUIRE_THAT(puml, IsClassTemplate("A", "char[1000]"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user