Fixed handling of unexposed variadic template params
This commit is contained in:
@@ -852,6 +852,12 @@ std::optional<template_parameter> build_template_parameter(
|
||||
|
||||
return res;
|
||||
}
|
||||
else if (common::is_type_token(*it) && *it_next == "...") {
|
||||
// Variadic template parameter
|
||||
auto parm = map_type_parameter_to_template_parameter(decl, *it);
|
||||
parm.is_variadic(true);
|
||||
return parm;
|
||||
}
|
||||
else if (common::is_type_token(*it) && *it_next == "(") {
|
||||
res.add_template_param(
|
||||
map_type_parameter_to_template_parameter(decl, *it));
|
||||
|
||||
@@ -563,6 +563,21 @@ std::vector<std::string> tokenize_unexposed_template_parameter(
|
||||
result.push_back("*");
|
||||
tok.clear();
|
||||
}
|
||||
else if (c == '.') {
|
||||
// This can only be the case if we have a variadic template,
|
||||
// right?
|
||||
if (tok == "..") {
|
||||
result.push_back("...");
|
||||
tok.clear();
|
||||
}
|
||||
else if (tok == ".") {
|
||||
tok = "..";
|
||||
}
|
||||
else if (!tok.empty()) {
|
||||
result.push_back(tok);
|
||||
tok = ".";
|
||||
}
|
||||
}
|
||||
else {
|
||||
tok += c;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,20 @@ TEST_CASE("t00062", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
|
||||
// Check if all classes exist
|
||||
REQUIRE_THAT(puml, IsClass(_A("AAA")));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "U &"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "U &&"));
|
||||
// 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::*)(Arg)"));
|
||||
// REQUIRE_THAT(puml, IsClassTemplate("A", "int (C::*)(bool)"));
|
||||
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", "char[N]"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "char[1000]"));
|
||||
|
||||
// Check if class templates exist
|
||||
// REQUIRE_THAT(puml, IsClassTemplate("A", "T,P,CMP,int N"));
|
||||
|
||||
@@ -384,4 +384,15 @@ TEST_CASE("Test tokenize_unexposed_template_parameter", "[unit-test]")
|
||||
CHECK(r[i++] == "unsigned");
|
||||
CHECK(r[i++] == "int");
|
||||
}
|
||||
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
auto r = tokenize_unexposed_template_parameter("Ret(Args...)");
|
||||
CHECK(r[i++] == "Ret");
|
||||
CHECK(r[i++] == "(");
|
||||
CHECK(r[i++] == "Args");
|
||||
CHECK(r[i++] == "...");
|
||||
CHECK(r[i++] == ")");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user