Override scope_name() in templates

This commit is contained in:
Jonathan Müller 2017-07-14 14:43:53 +02:00
commit 68f2ab91a0
7 changed files with 24 additions and 9 deletions

View file

@ -57,6 +57,7 @@ using h = g<T, a>;
auto file = parse(idx, "cpp_alias_template.cpp", code);
auto count = test_visit<cpp_alias_template>(*file, [&](const cpp_alias_template& alias) {
REQUIRE(is_templated(alias.type_alias()));
REQUIRE(!alias.scope_name());
if (alias.name() == "a")
{
@ -66,8 +67,9 @@ using h = g<T, a>;
}
else if (alias.name() == "b")
{
check_template_parameters(alias, {{cpp_entity_kind::non_type_template_parameter_t, "I"},
{cpp_entity_kind::template_type_parameter_t, "T"}});
check_template_parameters(alias,
{{cpp_entity_kind::non_type_template_parameter_t, "I"},
{cpp_entity_kind::template_type_parameter_t, "T"}});
REQUIRE(equal_types(idx, alias.type_alias().underlying_type(),
*cpp_template_parameter_type::build(
cpp_template_type_parameter_ref(cpp_entity_id(""), "T"))));

View file

@ -100,6 +100,7 @@ struct b<0, T> {};
auto& c = templ.class_();
REQUIRE(!c.is_final());
REQUIRE(is_templated(c));
REQUIRE(templ.scope_name());
if (templ.name() == "a")
{
@ -109,8 +110,9 @@ struct b<0, T> {};
}
else if (templ.name() == "b")
{
check_template_parameters(templ, {{cpp_entity_kind::non_type_template_parameter_t, "I"},
{cpp_entity_kind::template_type_parameter_t, "T"}});
check_template_parameters(templ,
{{cpp_entity_kind::non_type_template_parameter_t, "I"},
{cpp_entity_kind::template_type_parameter_t, "T"}});
REQUIRE(c.class_kind() == cpp_class_kind::struct_t);
REQUIRE(c.is_definition());
}
@ -224,6 +226,7 @@ struct b<0, T> {};
count = test_visit<cpp_class_template_specialization>(
*file, [&](const cpp_class_template_specialization& templ) {
REQUIRE(!templ.arguments_exposed());
REQUIRE(templ.scope_name());
if (templ.name() == "a")
{

View file

@ -75,6 +75,7 @@ d::d(const int&);
auto file = parse(idx, "cpp_function_template.cpp", code);
auto count = test_visit<cpp_function_template>(*file, [&](const cpp_function_template& tfunc) {
REQUIRE(is_templated(tfunc.function()));
REQUIRE(!tfunc.scope_name());
if (tfunc.name() == "a")
{
@ -104,8 +105,9 @@ d::d(const int&);
else if (tfunc.name() == "b")
{
check_parent(tfunc, "d", "d::b");
check_template_parameters(tfunc, {{cpp_entity_kind::non_type_template_parameter_t, "I"},
{cpp_entity_kind::template_type_parameter_t, "T"}});
check_template_parameters(tfunc,
{{cpp_entity_kind::non_type_template_parameter_t, "I"},
{cpp_entity_kind::template_type_parameter_t, "T"}});
REQUIRE(tfunc.function().kind() == cpp_entity_kind::function_t);
auto& func = static_cast<const cpp_function&>(tfunc.function());
@ -183,6 +185,7 @@ d::d(const int&);
*file, [&](const cpp_function_template_specialization& tfunc) {
REQUIRE(tfunc.is_full_specialization());
REQUIRE(!tfunc.arguments_exposed());
REQUIRE(!tfunc.scope_name());
auto templ = tfunc.primary_template();
if (tfunc.name() == "operator int")