Add and use cpp_token_string for unexposed entities
This commit is contained in:
parent
e53fc5e231
commit
0672e85186
29 changed files with 789 additions and 481 deletions
|
|
@ -110,9 +110,8 @@ 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());
|
||||
}
|
||||
|
|
@ -223,45 +222,46 @@ struct b<0, T> {};
|
|||
});
|
||||
REQUIRE(count == 5u);
|
||||
|
||||
count = test_visit<cpp_class_template_specialization>(
|
||||
*file, [&](const cpp_class_template_specialization& templ) {
|
||||
REQUIRE(!templ.arguments_exposed());
|
||||
REQUIRE(templ.scope_name());
|
||||
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")
|
||||
if (templ.name() == "a")
|
||||
{
|
||||
REQUIRE(
|
||||
equal_ref(idx, templ.primary_template(), cpp_template_ref(cpp_entity_id(""), "a")));
|
||||
if (templ.is_full_specialization())
|
||||
{
|
||||
REQUIRE(equal_ref(idx, templ.primary_template(),
|
||||
cpp_template_ref(cpp_entity_id(""), "a")));
|
||||
if (templ.is_full_specialization())
|
||||
{
|
||||
check_template_parameters(templ, {});
|
||||
REQUIRE(templ.unexposed_arguments() == "int");
|
||||
}
|
||||
else
|
||||
{
|
||||
check_template_parameters(templ,
|
||||
{{cpp_entity_kind::template_type_parameter_t, "T"}});
|
||||
REQUIRE(templ.unexposed_arguments() == "T*");
|
||||
}
|
||||
}
|
||||
else if (templ.name() == "b")
|
||||
{
|
||||
REQUIRE(equal_ref(idx, templ.primary_template(),
|
||||
cpp_template_ref(cpp_entity_id(""), "b")));
|
||||
if (templ.is_full_specialization())
|
||||
{
|
||||
check_template_parameters(templ, {});
|
||||
REQUIRE(templ.unexposed_arguments() == "0,int");
|
||||
}
|
||||
else
|
||||
{
|
||||
check_template_parameters(templ,
|
||||
{{cpp_entity_kind::template_type_parameter_t, "T"}});
|
||||
REQUIRE(templ.unexposed_arguments() == "0,T");
|
||||
}
|
||||
check_template_parameters(templ, {});
|
||||
REQUIRE(templ.unexposed_arguments().as_string() == "int");
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
});
|
||||
{
|
||||
check_template_parameters(templ,
|
||||
{{cpp_entity_kind::template_type_parameter_t, "T"}});
|
||||
REQUIRE(templ.unexposed_arguments().as_string() == "T*");
|
||||
}
|
||||
}
|
||||
else if (templ.name() == "b")
|
||||
{
|
||||
REQUIRE(
|
||||
equal_ref(idx, templ.primary_template(), cpp_template_ref(cpp_entity_id(""), "b")));
|
||||
if (templ.is_full_specialization())
|
||||
{
|
||||
check_template_parameters(templ, {});
|
||||
REQUIRE(templ.unexposed_arguments().as_string() == "0,int");
|
||||
}
|
||||
else
|
||||
{
|
||||
check_template_parameters(templ,
|
||||
{{cpp_entity_kind::template_type_parameter_t, "T"}});
|
||||
REQUIRE(templ.unexposed_arguments().as_string() == "0,T");
|
||||
}
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
});
|
||||
REQUIRE(count == 4u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ enum ns::c : int {};
|
|||
)";
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_enum.cpp", code);
|
||||
auto count = test_visit<cpp_enum>(*file, [&](const cpp_enum& e) {
|
||||
auto file = parse(idx, "cpp_enum.cpp", code);
|
||||
auto count = test_visit<cpp_enum>(*file, [&](const cpp_enum& e) {
|
||||
if (e.name() == "a")
|
||||
{
|
||||
REQUIRE(e.is_definition());
|
||||
|
|
@ -80,7 +80,9 @@ enum ns::c : int {};
|
|||
if (equal_types(idx, expr.type(), *cpp_builtin_type::build(cpp_uint)))
|
||||
{
|
||||
REQUIRE(expr.kind() == cpp_expression_kind::unexposed_t);
|
||||
REQUIRE(static_cast<const cpp_unexposed_expression&>(expr).expression()
|
||||
REQUIRE(static_cast<const cpp_unexposed_expression&>(expr)
|
||||
.expression()
|
||||
.as_string()
|
||||
== "42");
|
||||
}
|
||||
else
|
||||
|
|
@ -96,8 +98,9 @@ enum ns::c : int {};
|
|||
REQUIRE(val.value());
|
||||
auto& expr = val.value().value();
|
||||
REQUIRE(expr.kind() == cpp_expression_kind::unexposed_t);
|
||||
REQUIRE(static_cast<const cpp_unexposed_expression&>(expr).expression()
|
||||
== "a_a+2");
|
||||
REQUIRE(
|
||||
static_cast<const cpp_unexposed_expression&>(expr).expression().as_string()
|
||||
== "a_a+2");
|
||||
if (!equal_types(idx, expr.type(), *cpp_builtin_type::build(cpp_int)))
|
||||
REQUIRE(equal_types(idx, expr.type(), *cpp_builtin_type::build(cpp_uint)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ int d() {}
|
|||
{
|
||||
REQUIRE(func.function().is_declaration());
|
||||
REQUIRE(!func.arguments_exposed());
|
||||
REQUIRE(func.unexposed_arguments() == "ns::h");
|
||||
REQUIRE(func.unexposed_arguments().as_string() == "ns::h");
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ void ns::l()
|
|||
};
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_function.cpp", code);
|
||||
auto count = test_visit<cpp_function>(*file, [&](const cpp_function& func) {
|
||||
auto file = parse(idx, "cpp_function.cpp", code);
|
||||
auto count = test_visit<cpp_function>(*file, [&](const cpp_function& func) {
|
||||
if (func.name() == "a" || func.name() == "b" || func.name() == "c")
|
||||
{
|
||||
REQUIRE(!func.noexcept_condition());
|
||||
|
|
@ -99,11 +99,12 @@ void ns::l()
|
|||
*cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_float))));
|
||||
REQUIRE(param.default_value());
|
||||
REQUIRE(equal_expressions(param.default_value().value(),
|
||||
*cpp_unexposed_expression::
|
||||
build(cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_float)),
|
||||
"nullptr")));
|
||||
REQUIRE(
|
||||
equal_expressions(param.default_value().value(),
|
||||
*cpp_unexposed_expression::
|
||||
build(cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_float)),
|
||||
cpp_token_string::from_string("nullptr"))));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
@ -130,12 +131,11 @@ void ns::l()
|
|||
{
|
||||
if (param.name() == "a")
|
||||
{
|
||||
REQUIRE(
|
||||
equal_types(idx, param.type(),
|
||||
*cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::build(cpp_builtin_type::build(
|
||||
cpp_int),
|
||||
"42"))));
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::
|
||||
build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::from_string("42")))));
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else
|
||||
|
|
@ -163,12 +163,15 @@ void ns::l()
|
|||
*cpp_literal_expression::build(std::move(bool_t), "true")));
|
||||
else if (func.name() == "e")
|
||||
REQUIRE(equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
"false")));
|
||||
*cpp_unexposed_expression::
|
||||
build(std::move(bool_t),
|
||||
cpp_token_string::from_string("false"))));
|
||||
else if (func.name() == "f")
|
||||
REQUIRE(equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
"noexcept(d())")));
|
||||
REQUIRE(
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::
|
||||
build(std::move(bool_t),
|
||||
cpp_token_string::from_string("noexcept(d())"))));
|
||||
}
|
||||
else if (func.name() == "g" || func.name() == "h" || func.name() == "i"
|
||||
|| func.name() == "j")
|
||||
|
|
@ -246,8 +249,8 @@ void foo::a() {}
|
|||
)";
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "static_cpp_function.cpp", code);
|
||||
auto count = test_visit<cpp_function>(*file, [&](const cpp_function& func) {
|
||||
auto file = parse(idx, "static_cpp_function.cpp", code);
|
||||
auto count = test_visit<cpp_function>(*file, [&](const cpp_function& func) {
|
||||
REQUIRE(!func.is_variadic());
|
||||
REQUIRE(func.signature() == "()");
|
||||
REQUIRE(func.storage_class() == cpp_storage_class_static);
|
||||
|
|
|
|||
|
|
@ -105,9 +105,8 @@ 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());
|
||||
|
|
@ -181,110 +180,109 @@ d::d(const int&);
|
|||
});
|
||||
REQUIRE(count == 5u);
|
||||
|
||||
count = test_visit<cpp_function_template_specialization>(
|
||||
*file, [&](const cpp_function_template_specialization& tfunc) {
|
||||
REQUIRE(tfunc.is_full_specialization());
|
||||
REQUIRE(!tfunc.arguments_exposed());
|
||||
REQUIRE(!tfunc.scope_name());
|
||||
count = test_visit<
|
||||
cpp_function_template_specialization>(*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")
|
||||
REQUIRE(equal_ref(idx, templ, cpp_template_ref(cpp_entity_id(""), tfunc.name()),
|
||||
"d::operator T"));
|
||||
else
|
||||
REQUIRE(equal_ref(idx, templ, cpp_template_ref(cpp_entity_id(""), tfunc.name()),
|
||||
(tfunc.function().semantic_scope() + tfunc.name()).c_str()));
|
||||
auto templ = tfunc.primary_template();
|
||||
if (tfunc.name() == "operator int")
|
||||
REQUIRE(equal_ref(idx, templ, cpp_template_ref(cpp_entity_id(""), tfunc.name()),
|
||||
"d::operator T"));
|
||||
else
|
||||
REQUIRE(equal_ref(idx, templ, cpp_template_ref(cpp_entity_id(""), tfunc.name()),
|
||||
(tfunc.function().semantic_scope() + tfunc.name()).c_str()));
|
||||
|
||||
if (tfunc.name() == "a")
|
||||
if (tfunc.name() == "a")
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments().empty());
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::function_t);
|
||||
auto& func = static_cast<const cpp_function&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "");
|
||||
|
||||
REQUIRE(equal_types(idx, func.return_type(), *cpp_builtin_type::build(cpp_int)));
|
||||
|
||||
auto count = 0u;
|
||||
for (auto& param : func.parameters())
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments() == "");
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::function_t);
|
||||
auto& func = static_cast<const cpp_function&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "");
|
||||
|
||||
REQUIRE(equal_types(idx, func.return_type(), *cpp_builtin_type::build(cpp_int)));
|
||||
|
||||
auto count = 0u;
|
||||
for (auto& param : func.parameters())
|
||||
{
|
||||
++count;
|
||||
REQUIRE(
|
||||
equal_types(idx, param.type(),
|
||||
++count;
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_reference_type::
|
||||
build(cpp_cv_qualified_type::build(cpp_builtin_type::build(
|
||||
cpp_int),
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue)));
|
||||
}
|
||||
REQUIRE(count == 1u);
|
||||
}
|
||||
else if (tfunc.name() == "b")
|
||||
REQUIRE(count == 1u);
|
||||
}
|
||||
else if (tfunc.name() == "b")
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments().as_string() == "0,int");
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::function_t);
|
||||
auto& func = static_cast<const cpp_function&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "d::");
|
||||
|
||||
cpp_template_instantiation_type::builder builder(
|
||||
cpp_template_ref(cpp_entity_id(""), "type"));
|
||||
builder.add_unexposed_arguments("0");
|
||||
REQUIRE(equal_types(idx, func.return_type(), *builder.finish()));
|
||||
|
||||
auto count = 0u;
|
||||
for (auto& param : func.parameters())
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments() == "0,int");
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::function_t);
|
||||
auto& func = static_cast<const cpp_function&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "d::");
|
||||
|
||||
cpp_template_instantiation_type::builder builder(
|
||||
cpp_template_ref(cpp_entity_id(""), "type"));
|
||||
builder.add_unexposed_arguments("0");
|
||||
REQUIRE(equal_types(idx, func.return_type(), *builder.finish()));
|
||||
|
||||
auto count = 0u;
|
||||
for (auto& param : func.parameters())
|
||||
{
|
||||
++count;
|
||||
REQUIRE(equal_types(idx, param.type(), *cpp_builtin_type::build(cpp_int)));
|
||||
}
|
||||
REQUIRE(count == 1u);
|
||||
++count;
|
||||
REQUIRE(equal_types(idx, param.type(), *cpp_builtin_type::build(cpp_int)));
|
||||
}
|
||||
else if (tfunc.name() == "c")
|
||||
REQUIRE(count == 1u);
|
||||
}
|
||||
else if (tfunc.name() == "c")
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments().empty());
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::member_function_t);
|
||||
auto& func = static_cast<const cpp_member_function&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "d::");
|
||||
REQUIRE(func.cv_qualifier() == cpp_cv_none);
|
||||
|
||||
REQUIRE(equal_types(idx, func.return_type(), *cpp_builtin_type::build(cpp_int)));
|
||||
}
|
||||
else if (tfunc.name() == "operator int")
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments().empty());
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::conversion_op_t);
|
||||
auto& func = static_cast<const cpp_conversion_op&>(tfunc.function());
|
||||
REQUIRE(func.cv_qualifier() == cpp_cv_const);
|
||||
|
||||
REQUIRE(equal_types(idx, func.return_type(), *cpp_builtin_type::build(cpp_int)));
|
||||
}
|
||||
else if (tfunc.name() == "d")
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments().empty());
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::constructor_t);
|
||||
auto& func = static_cast<const cpp_constructor&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "d::");
|
||||
|
||||
auto count = 0u;
|
||||
for (auto& param : func.parameters())
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments() == "");
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::member_function_t);
|
||||
auto& func = static_cast<const cpp_member_function&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "d::");
|
||||
REQUIRE(func.cv_qualifier() == cpp_cv_none);
|
||||
|
||||
REQUIRE(equal_types(idx, func.return_type(), *cpp_builtin_type::build(cpp_int)));
|
||||
}
|
||||
else if (tfunc.name() == "operator int")
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments() == "");
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::conversion_op_t);
|
||||
auto& func = static_cast<const cpp_conversion_op&>(tfunc.function());
|
||||
REQUIRE(func.cv_qualifier() == cpp_cv_const);
|
||||
|
||||
REQUIRE(equal_types(idx, func.return_type(), *cpp_builtin_type::build(cpp_int)));
|
||||
}
|
||||
else if (tfunc.name() == "d")
|
||||
{
|
||||
REQUIRE(tfunc.unexposed_arguments() == "");
|
||||
|
||||
REQUIRE(tfunc.function().kind() == cpp_entity_kind::constructor_t);
|
||||
auto& func = static_cast<const cpp_constructor&>(tfunc.function());
|
||||
REQUIRE(func.semantic_scope() == "d::");
|
||||
|
||||
auto count = 0u;
|
||||
for (auto& param : func.parameters())
|
||||
{
|
||||
++count;
|
||||
REQUIRE(
|
||||
equal_types(idx, param.type(),
|
||||
++count;
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_reference_type::
|
||||
build(cpp_cv_qualified_type::build(cpp_builtin_type::build(
|
||||
cpp_int),
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue)));
|
||||
}
|
||||
REQUIRE(count == 1u);
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
});
|
||||
REQUIRE(count == 1u);
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
});
|
||||
REQUIRE(count == 5u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ struct foo
|
|||
)";
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_conversion_op.cpp", code);
|
||||
auto count = test_visit<cpp_conversion_op>(*file, [&](const cpp_conversion_op& op) {
|
||||
auto file = parse(idx, "cpp_conversion_op.cpp", code);
|
||||
auto count = test_visit<cpp_conversion_op>(*file, [&](const cpp_conversion_op& op) {
|
||||
REQUIRE(count_children(op.parameters()) == 0u);
|
||||
REQUIRE(!op.is_variadic());
|
||||
REQUIRE(op.body_kind() == cpp_function_definition);
|
||||
|
|
@ -301,8 +301,8 @@ foo<T>::foo(int) {}
|
|||
}
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_constructor.cpp", code);
|
||||
auto count = test_visit<cpp_constructor>(*file, [&](const cpp_constructor& cont) {
|
||||
auto file = parse(idx, "cpp_constructor.cpp", code);
|
||||
auto count = test_visit<cpp_constructor>(*file, [&](const cpp_constructor& cont) {
|
||||
REQUIRE(!cont.is_variadic());
|
||||
REQUIRE(cont.name() == "foo");
|
||||
|
||||
|
|
@ -402,10 +402,12 @@ d::~d() {}
|
|||
REQUIRE(!dtor.is_virtual());
|
||||
REQUIRE(dtor.body_kind() == cpp_function_definition);
|
||||
REQUIRE(dtor.noexcept_condition());
|
||||
REQUIRE(equal_expressions(dtor.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(
|
||||
cpp_bool),
|
||||
"false")));
|
||||
REQUIRE(
|
||||
equal_expressions(dtor.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(
|
||||
cpp_bool),
|
||||
cpp_token_string::from_string(
|
||||
"false"))));
|
||||
}
|
||||
else if (dtor.name() == "~c")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ struct foo
|
|||
REQUIRE(equal_types(idx, var.type(), *type));
|
||||
|
||||
// all initializers are unexposed
|
||||
auto def = cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_float), "3.14f");
|
||||
auto def = cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_float),
|
||||
cpp_token_string::from_string("3.14f"));
|
||||
REQUIRE(var.default_value());
|
||||
REQUIRE(equal_expressions(var.default_value().value(), *def));
|
||||
|
||||
|
|
|
|||
|
|
@ -34,12 +34,17 @@ struct foo
|
|||
REQUIRE(equal_expressions(assert.expression(),
|
||||
*cpp_literal_expression::build(std::move(bool_t), "true")));
|
||||
else if (assert.message() == "a")
|
||||
REQUIRE(equal_expressions(assert.expression(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
"true||false")));
|
||||
REQUIRE(
|
||||
equal_expressions(assert.expression(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
cpp_token_string::from_string(
|
||||
"true||false"))));
|
||||
else if (assert.message() == "b")
|
||||
REQUIRE(equal_expressions(assert.expression(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t), "!B")));
|
||||
REQUIRE(
|
||||
equal_expressions(assert.expression(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
cpp_token_string::from_string(
|
||||
"!B"))));
|
||||
else
|
||||
REQUIRE(false);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -34,83 +34,72 @@ using e = void;
|
|||
)";
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_template_type_parameter.cpp", code);
|
||||
auto count =
|
||||
test_visit<cpp_alias_template>(*file,
|
||||
[&](const cpp_alias_template& alias) {
|
||||
REQUIRE(equal_types(idx,
|
||||
alias.type_alias().underlying_type(),
|
||||
*cpp_builtin_type::build(cpp_void)));
|
||||
auto file = parse(idx, "cpp_template_type_parameter.cpp", code);
|
||||
auto count = test_visit<
|
||||
cpp_alias_template>(*file,
|
||||
[&](const cpp_alias_template& alias) {
|
||||
REQUIRE(equal_types(idx, alias.type_alias().underlying_type(),
|
||||
*cpp_builtin_type::build(cpp_void)));
|
||||
|
||||
for (auto& p : alias.parameters())
|
||||
{
|
||||
REQUIRE(
|
||||
p.kind()
|
||||
== cpp_entity_kind::template_type_parameter_t);
|
||||
for (auto& p : alias.parameters())
|
||||
{
|
||||
REQUIRE(p.kind() == cpp_entity_kind::template_type_parameter_t);
|
||||
|
||||
auto& param =
|
||||
static_cast<const cpp_template_type_parameter&>(
|
||||
p);
|
||||
if (param.name() == "A")
|
||||
{
|
||||
REQUIRE(alias.name() == "a");
|
||||
REQUIRE(
|
||||
param.keyword()
|
||||
== cpp_template_keyword::keyword_typename);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_type());
|
||||
}
|
||||
else if (param.name() == "B")
|
||||
{
|
||||
REQUIRE(alias.name() == "b");
|
||||
REQUIRE(param.keyword()
|
||||
== cpp_template_keyword::keyword_class);
|
||||
REQUIRE(param.is_variadic());
|
||||
REQUIRE(!param.default_type());
|
||||
}
|
||||
else if (param.name() == "")
|
||||
{
|
||||
REQUIRE(alias.name() == "c");
|
||||
REQUIRE(
|
||||
param.keyword()
|
||||
== cpp_template_keyword::keyword_typename);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_type().has_value());
|
||||
REQUIRE(equal_types(idx,
|
||||
param.default_type().value(),
|
||||
*cpp_unexposed_type::build(
|
||||
"const int*")));
|
||||
}
|
||||
else if (param.name() == "D")
|
||||
{
|
||||
REQUIRE(alias.name() == "d");
|
||||
REQUIRE(param.keyword()
|
||||
== cpp_template_keyword::keyword_class);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_type().has_value());
|
||||
REQUIRE(equal_types(idx,
|
||||
param.default_type().value(),
|
||||
*cpp_unexposed_type::build(
|
||||
"decltype(1+3)")));
|
||||
}
|
||||
else if (param.name() == "E")
|
||||
{
|
||||
REQUIRE(alias.name() == "e");
|
||||
REQUIRE(
|
||||
param.keyword()
|
||||
== cpp_template_keyword::keyword_typename);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_type().has_value());
|
||||
REQUIRE(equal_types(idx,
|
||||
param.default_type().value(),
|
||||
*cpp_unexposed_type::build(
|
||||
"a<void>")));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
}
|
||||
},
|
||||
false); // can't check synopsis with comments
|
||||
auto& param =
|
||||
static_cast<const cpp_template_type_parameter&>(p);
|
||||
if (param.name() == "A")
|
||||
{
|
||||
REQUIRE(alias.name() == "a");
|
||||
REQUIRE(param.keyword()
|
||||
== cpp_template_keyword::keyword_typename);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_type());
|
||||
}
|
||||
else if (param.name() == "B")
|
||||
{
|
||||
REQUIRE(alias.name() == "b");
|
||||
REQUIRE(param.keyword()
|
||||
== cpp_template_keyword::keyword_class);
|
||||
REQUIRE(param.is_variadic());
|
||||
REQUIRE(!param.default_type());
|
||||
}
|
||||
else if (param.name() == "")
|
||||
{
|
||||
REQUIRE(alias.name() == "c");
|
||||
REQUIRE(param.keyword()
|
||||
== cpp_template_keyword::keyword_typename);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_type().has_value());
|
||||
REQUIRE(
|
||||
equal_types(idx, param.default_type().value(),
|
||||
*cpp_unexposed_type::build("const int*")));
|
||||
}
|
||||
else if (param.name() == "D")
|
||||
{
|
||||
REQUIRE(alias.name() == "d");
|
||||
REQUIRE(param.keyword()
|
||||
== cpp_template_keyword::keyword_class);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_type().has_value());
|
||||
REQUIRE(equal_types(idx, param.default_type().value(),
|
||||
*cpp_unexposed_type::build(
|
||||
"decltype(1+3)")));
|
||||
}
|
||||
else if (param.name() == "E")
|
||||
{
|
||||
REQUIRE(alias.name() == "e");
|
||||
REQUIRE(param.keyword()
|
||||
== cpp_template_keyword::keyword_typename);
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_type().has_value());
|
||||
REQUIRE(equal_types(idx, param.default_type().value(),
|
||||
*cpp_unexposed_type::build("a<void>")));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
}
|
||||
},
|
||||
false); // can't check synopsis with comments
|
||||
REQUIRE(count == 5u);
|
||||
}
|
||||
|
||||
|
|
@ -132,61 +121,71 @@ using d = void;
|
|||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_non_type_template_parameter.cpp", code);
|
||||
auto count = test_visit<cpp_alias_template>(
|
||||
*file,
|
||||
[&](const cpp_alias_template& alias) {
|
||||
REQUIRE(equal_types(idx, alias.type_alias().underlying_type(),
|
||||
*cpp_builtin_type::build(cpp_void)));
|
||||
auto count = test_visit<
|
||||
cpp_alias_template>(*file,
|
||||
[&](const cpp_alias_template& alias) {
|
||||
REQUIRE(equal_types(idx, alias.type_alias().underlying_type(),
|
||||
*cpp_builtin_type::build(cpp_void)));
|
||||
|
||||
for (auto& p : alias.parameters())
|
||||
{
|
||||
REQUIRE(p.kind() == cpp_entity_kind::non_type_template_parameter_t);
|
||||
for (auto& p : alias.parameters())
|
||||
{
|
||||
REQUIRE(p.kind()
|
||||
== cpp_entity_kind::non_type_template_parameter_t);
|
||||
|
||||
auto& param = static_cast<const cpp_non_type_template_parameter&>(p);
|
||||
if (param.name() == "A")
|
||||
{
|
||||
REQUIRE(alias.name() == "a");
|
||||
REQUIRE(equal_types(idx, param.type(), *cpp_builtin_type::build(cpp_int)));
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else if (param.name() == "")
|
||||
{
|
||||
REQUIRE(alias.name() == "b");
|
||||
REQUIRE(equal_types(idx, param.type(), *cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_char))));
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_value());
|
||||
REQUIRE(
|
||||
equal_expressions(param.default_value().value(),
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(
|
||||
cpp_nullptr),
|
||||
"nullptr")));
|
||||
}
|
||||
else if (param.name() == "C")
|
||||
{
|
||||
REQUIRE(alias.name() == "c");
|
||||
REQUIRE(equal_types(idx, param.type(), *cpp_builtin_type::build(cpp_int)));
|
||||
REQUIRE(param.is_variadic());
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else if (param.name() == "D")
|
||||
{
|
||||
REQUIRE(alias.name() == "d");
|
||||
auto& param =
|
||||
static_cast<const cpp_non_type_template_parameter&>(p);
|
||||
if (param.name() == "A")
|
||||
{
|
||||
REQUIRE(alias.name() == "a");
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_builtin_type::build(cpp_int)));
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else if (param.name() == "")
|
||||
{
|
||||
REQUIRE(alias.name() == "b");
|
||||
REQUIRE(
|
||||
equal_types(idx, param.type(),
|
||||
*cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_char))));
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_value());
|
||||
REQUIRE(equal_expressions(param.default_value().value(),
|
||||
*cpp_unexposed_expression::
|
||||
build(cpp_builtin_type::build(
|
||||
cpp_nullptr),
|
||||
cpp_token_string::
|
||||
from_string(
|
||||
"nullptr"))));
|
||||
}
|
||||
else if (param.name() == "C")
|
||||
{
|
||||
REQUIRE(alias.name() == "c");
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_builtin_type::build(cpp_int)));
|
||||
REQUIRE(param.is_variadic());
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else if (param.name() == "D")
|
||||
{
|
||||
REQUIRE(alias.name() == "d");
|
||||
|
||||
cpp_function_type::builder builder(cpp_builtin_type::build(cpp_void));
|
||||
builder.is_variadic();
|
||||
REQUIRE(
|
||||
equal_types(idx, param.type(), *cpp_pointer_type::build(builder.finish())));
|
||||
cpp_function_type::builder builder(
|
||||
cpp_builtin_type::build(cpp_void));
|
||||
builder.is_variadic();
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_pointer_type::build(
|
||||
builder.finish())));
|
||||
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
}
|
||||
},
|
||||
false); // can't check synopsis with comments
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
}
|
||||
},
|
||||
false); // can't check synopsis with comments
|
||||
REQUIRE(count == 4u);
|
||||
}
|
||||
|
||||
|
|
@ -215,109 +214,122 @@ using d = void;
|
|||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_template_template_parameter.cpp", code);
|
||||
auto count = test_visit<cpp_alias_template>(
|
||||
*file,
|
||||
[&](const cpp_alias_template& alias) {
|
||||
REQUIRE(equal_types(idx, alias.type_alias().underlying_type(),
|
||||
*cpp_builtin_type::build(cpp_void)));
|
||||
if (alias.name() == "def")
|
||||
return;
|
||||
auto count = test_visit<
|
||||
cpp_alias_template>(*file,
|
||||
[&](const cpp_alias_template& alias) {
|
||||
REQUIRE(equal_types(idx, alias.type_alias().underlying_type(),
|
||||
*cpp_builtin_type::build(cpp_void)));
|
||||
if (alias.name() == "def")
|
||||
return;
|
||||
|
||||
for (auto& p : alias.parameters())
|
||||
{
|
||||
REQUIRE(p.kind() == cpp_entity_kind::template_template_parameter_t);
|
||||
for (auto& p : alias.parameters())
|
||||
{
|
||||
REQUIRE(p.kind()
|
||||
== cpp_entity_kind::template_template_parameter_t);
|
||||
|
||||
auto& param = static_cast<const cpp_template_template_parameter&>(p);
|
||||
REQUIRE(param.keyword() == cpp_template_keyword::keyword_class);
|
||||
if (param.name() == "A")
|
||||
{
|
||||
REQUIRE(alias.name() == "a");
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_template());
|
||||
auto& param =
|
||||
static_cast<const cpp_template_template_parameter&>(p);
|
||||
REQUIRE(param.keyword() == cpp_template_keyword::keyword_class);
|
||||
if (param.name() == "A")
|
||||
{
|
||||
REQUIRE(alias.name() == "a");
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(!param.default_template());
|
||||
|
||||
auto no = 0u;
|
||||
for (auto& p_param : param.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_param.name() == "T");
|
||||
REQUIRE(p_param.kind() == cpp_entity_kind::template_type_parameter_t);
|
||||
}
|
||||
REQUIRE(no == 1u);
|
||||
}
|
||||
else if (param.name() == "B")
|
||||
{
|
||||
REQUIRE(alias.name() == "b");
|
||||
REQUIRE(param.is_variadic());
|
||||
REQUIRE(!param.default_template());
|
||||
auto no = 0u;
|
||||
for (auto& p_param : param.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_param.name() == "T");
|
||||
REQUIRE(p_param.kind()
|
||||
== cpp_entity_kind::template_type_parameter_t);
|
||||
}
|
||||
REQUIRE(no == 1u);
|
||||
}
|
||||
else if (param.name() == "B")
|
||||
{
|
||||
REQUIRE(alias.name() == "b");
|
||||
REQUIRE(param.is_variadic());
|
||||
REQUIRE(!param.default_template());
|
||||
|
||||
auto cur = param.parameters().begin();
|
||||
REQUIRE(cur != param.parameters().end());
|
||||
REQUIRE(cur->name().empty());
|
||||
REQUIRE(cur->kind() == cpp_entity_kind::non_type_template_parameter_t);
|
||||
auto cur = param.parameters().begin();
|
||||
REQUIRE(cur != param.parameters().end());
|
||||
REQUIRE(cur->name().empty());
|
||||
REQUIRE(cur->kind()
|
||||
== cpp_entity_kind::non_type_template_parameter_t);
|
||||
|
||||
++cur;
|
||||
REQUIRE(cur != param.parameters().end());
|
||||
REQUIRE(cur->name().empty());
|
||||
REQUIRE(cur->kind() == cpp_entity_kind::template_type_parameter_t);
|
||||
++cur;
|
||||
REQUIRE(cur != param.parameters().end());
|
||||
REQUIRE(cur->name().empty());
|
||||
REQUIRE(cur->kind()
|
||||
== cpp_entity_kind::template_type_parameter_t);
|
||||
|
||||
++cur;
|
||||
REQUIRE(cur == param.parameters().end());
|
||||
}
|
||||
else if (param.name() == "C")
|
||||
{
|
||||
REQUIRE(alias.name() == "c");
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_template());
|
||||
++cur;
|
||||
REQUIRE(cur == param.parameters().end());
|
||||
}
|
||||
else if (param.name() == "C")
|
||||
{
|
||||
REQUIRE(alias.name() == "c");
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_template());
|
||||
|
||||
auto def = param.default_template().value();
|
||||
REQUIRE(def.name() == "ns::def");
|
||||
auto entities = def.get(idx);
|
||||
REQUIRE(entities.size() == 1u);
|
||||
REQUIRE(entities[0]->name() == "def");
|
||||
auto def = param.default_template().value();
|
||||
REQUIRE(def.name() == "ns::def");
|
||||
auto entities = def.get(idx);
|
||||
REQUIRE(entities.size() == 1u);
|
||||
REQUIRE(entities[0]->name() == "def");
|
||||
|
||||
auto no = 0u;
|
||||
for (auto& p_param : param.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_param.name() == "");
|
||||
REQUIRE(p_param.kind() == cpp_entity_kind::non_type_template_parameter_t);
|
||||
}
|
||||
REQUIRE(no == 1u);
|
||||
}
|
||||
else if (param.name() == "D")
|
||||
{
|
||||
REQUIRE(alias.name() == "d");
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_template());
|
||||
auto no = 0u;
|
||||
for (auto& p_param : param.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_param.name() == "");
|
||||
REQUIRE(
|
||||
p_param.kind()
|
||||
== cpp_entity_kind::non_type_template_parameter_t);
|
||||
}
|
||||
REQUIRE(no == 1u);
|
||||
}
|
||||
else if (param.name() == "D")
|
||||
{
|
||||
REQUIRE(alias.name() == "d");
|
||||
REQUIRE(!param.is_variadic());
|
||||
REQUIRE(param.default_template());
|
||||
|
||||
auto def = param.default_template().value();
|
||||
REQUIRE(def.name() == "a");
|
||||
auto entities = def.get(idx);
|
||||
REQUIRE(entities.size() == 1u);
|
||||
REQUIRE(entities[0]->name() == "a");
|
||||
auto def = param.default_template().value();
|
||||
REQUIRE(def.name() == "a");
|
||||
auto entities = def.get(idx);
|
||||
REQUIRE(entities.size() == 1u);
|
||||
REQUIRE(entities[0]->name() == "a");
|
||||
|
||||
auto no = 0u;
|
||||
for (auto& p_param : param.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_param.name() == "");
|
||||
REQUIRE(p_param.kind() == cpp_entity_kind::template_template_parameter_t);
|
||||
for (auto& p_p_param :
|
||||
static_cast<const cpp_template_template_parameter&>(p_param)
|
||||
.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_p_param.name() == "");
|
||||
REQUIRE(p_p_param.kind() == cpp_entity_kind::template_type_parameter_t);
|
||||
REQUIRE(p_p_param.is_variadic());
|
||||
}
|
||||
}
|
||||
REQUIRE(no == 2u);
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
}
|
||||
},
|
||||
false); // can't check synopsis with comments
|
||||
auto no = 0u;
|
||||
for (auto& p_param : param.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_param.name() == "");
|
||||
REQUIRE(
|
||||
p_param.kind()
|
||||
== cpp_entity_kind::template_template_parameter_t);
|
||||
for (auto& p_p_param :
|
||||
static_cast<
|
||||
const cpp_template_template_parameter&>(
|
||||
p_param)
|
||||
.parameters())
|
||||
{
|
||||
++no;
|
||||
REQUIRE(p_p_param.name() == "");
|
||||
REQUIRE(
|
||||
p_p_param.kind()
|
||||
== cpp_entity_kind::template_type_parameter_t);
|
||||
REQUIRE(p_p_param.is_variadic());
|
||||
}
|
||||
}
|
||||
REQUIRE(no == 2u);
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
}
|
||||
},
|
||||
false); // can't check synopsis with comments
|
||||
REQUIRE(count == 5u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,12 +333,13 @@ typedef decltype(0) w;
|
|||
if (literal)
|
||||
return cpp_literal_expression::build(std::move(type), std::move(size));
|
||||
else
|
||||
return cpp_unexposed_expression::build(std::move(type), std::move(size));
|
||||
return cpp_unexposed_expression::build(std::move(type),
|
||||
cpp_token_string::from_string(std::move(size)));
|
||||
};
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto file = parse(idx, "cpp_type_alias.cpp", code);
|
||||
auto count = test_visit<cpp_type_alias>(*file, [&](const cpp_type_alias& alias) {
|
||||
auto file = parse(idx, "cpp_type_alias.cpp", code);
|
||||
auto count = test_visit<cpp_type_alias>(*file, [&](const cpp_type_alias& alias) {
|
||||
if (alias.name() == "a")
|
||||
{
|
||||
auto type = cpp_builtin_type::build(cpp_int);
|
||||
|
|
@ -505,7 +506,8 @@ typedef decltype(0) w;
|
|||
else if (alias.name() == "w")
|
||||
{
|
||||
auto type = cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int), "0"));
|
||||
cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::from_string("0")));
|
||||
REQUIRE(equal_types(idx, alias.underlying_type(), *type));
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ int r[] = {0};
|
|||
)";
|
||||
|
||||
cpp_entity_index idx;
|
||||
auto check_variable = [&](const cpp_variable& var, const cpp_type& type,
|
||||
auto check_variable = [&](const cpp_variable& var, const cpp_type& type,
|
||||
type_safe::optional_ref<const cpp_expression> default_value,
|
||||
int storage_class, bool is_constexpr, bool is_declaration) {
|
||||
if (is_declaration)
|
||||
|
|
@ -101,13 +101,15 @@ int r[] = {0};
|
|||
// unexposed due to implicit cast, I think
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
"42")),
|
||||
cpp_token_string::from_string(
|
||||
"42"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "c")
|
||||
check_variable(var, *cpp_builtin_type::build(cpp_float),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_float),
|
||||
"3.f+0.14f")),
|
||||
cpp_token_string::from_string(
|
||||
"3.f+0.14f"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "d")
|
||||
check_variable(var, *int_type, nullptr, cpp_storage_class_extern, false, true);
|
||||
|
|
@ -119,11 +121,13 @@ int r[] = {0};
|
|||
check_variable(var, *int_type, nullptr,
|
||||
cpp_storage_class_static | cpp_storage_class_thread_local, false, false);
|
||||
else if (var.name() == "h")
|
||||
check_variable(var, *cpp_cv_qualified_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_cv_const),
|
||||
check_variable(var,
|
||||
*cpp_cv_qualified_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_cv_const),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
"12")),
|
||||
cpp_token_string::from_string(
|
||||
"12"))),
|
||||
cpp_storage_class_none, true, false);
|
||||
else if (var.name() == "i")
|
||||
{
|
||||
|
|
@ -134,15 +138,17 @@ int r[] = {0};
|
|||
}
|
||||
else if (var.name() == "j")
|
||||
{
|
||||
check_variable(var, *cpp_cv_qualified_type::build(cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""),
|
||||
"bar")),
|
||||
cpp_cv_const),
|
||||
check_variable(var,
|
||||
*cpp_cv_qualified_type::build(cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""),
|
||||
"bar")),
|
||||
cpp_cv_const),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""),
|
||||
"bar")),
|
||||
"bar()")),
|
||||
cpp_token_string::from_string(
|
||||
"bar()"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -163,35 +169,40 @@ int r[] = {0};
|
|||
check_variable(var, *cpp_auto_type::build(),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
"128")),
|
||||
cpp_token_string::from_string(
|
||||
"128"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "n")
|
||||
check_variable(var, *cpp_reference_type::
|
||||
build(cpp_cv_qualified_type::build(cpp_auto_type::build(),
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue),
|
||||
check_variable(var,
|
||||
*cpp_reference_type::
|
||||
build(cpp_cv_qualified_type::build(cpp_auto_type::build(),
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
"m")),
|
||||
cpp_token_string::from_string(
|
||||
"m"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "o")
|
||||
check_variable(var,
|
||||
*cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
"0")),
|
||||
cpp_token_string::from_string("0"))),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "p")
|
||||
check_variable(var, *cpp_reference_type::
|
||||
build(cpp_cv_qualified_type::
|
||||
build(cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::
|
||||
build(cpp_builtin_type::build(cpp_int),
|
||||
"o")),
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue),
|
||||
check_variable(var,
|
||||
*cpp_reference_type::
|
||||
build(cpp_cv_qualified_type::
|
||||
build(cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::
|
||||
build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::from_string("o"))),
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
"o")),
|
||||
cpp_token_string::from_string(
|
||||
"o"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "q")
|
||||
check_variable(var,
|
||||
|
|
@ -208,7 +219,8 @@ int r[] = {0};
|
|||
"1")),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_unexposed_type::build(""),
|
||||
"{0}")),
|
||||
cpp_token_string::from_string(
|
||||
"{0}"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
|
|||
|
|
@ -49,9 +49,7 @@ inline std::unique_ptr<cppast::cpp_file> parse(const cppast::cpp_entity_index& i
|
|||
class test_generator : public cppast::code_generator
|
||||
{
|
||||
public:
|
||||
test_generator(generation_options options) : options_(std::move(options))
|
||||
{
|
||||
}
|
||||
test_generator(generation_options options) : options_(std::move(options)) {}
|
||||
|
||||
const std::string& str() const noexcept
|
||||
{
|
||||
|
|
@ -205,8 +203,10 @@ inline bool equal_expressions(const cppast::cpp_expression& parsed,
|
|||
switch (parsed.kind())
|
||||
{
|
||||
case cpp_expression_kind::unexposed_t:
|
||||
return static_cast<const cpp_unexposed_expression&>(parsed).expression()
|
||||
== static_cast<const cpp_unexposed_expression&>(synthesized).expression();
|
||||
return static_cast<const cpp_unexposed_expression&>(parsed).expression().as_string()
|
||||
== static_cast<const cpp_unexposed_expression&>(synthesized)
|
||||
.expression()
|
||||
.as_string();
|
||||
|
||||
case cpp_expression_kind::literal_t:
|
||||
return static_cast<const cpp_literal_expression&>(parsed).value()
|
||||
|
|
@ -217,10 +217,10 @@ inline bool equal_expressions(const cppast::cpp_expression& parsed,
|
|||
}
|
||||
|
||||
template <typename T, class Predicate>
|
||||
bool equal_ref(const cppast::cpp_entity_index& idx,
|
||||
bool equal_ref(const cppast::cpp_entity_index& idx,
|
||||
const cppast::basic_cpp_entity_ref<T, Predicate>& parsed,
|
||||
const cppast::basic_cpp_entity_ref<T, Predicate>& synthesized,
|
||||
const char* full_name_override = nullptr)
|
||||
const char* full_name_override = nullptr)
|
||||
{
|
||||
if (parsed.name() != synthesized.name())
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue