Update copyright notices
This commit is contained in:
parent
373717cc5e
commit
62e571a4d6
133 changed files with 936 additions and 1103 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (C) 2017-2018 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
# This file is subject to the license terms in the LICENSE file
|
||||
# Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
# found in the top-level directory of this distribution.
|
||||
|
||||
# Fetch catch.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/code_generator.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_alias_template.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_attribute.hpp>
|
||||
|
||||
|
|
@ -63,103 +62,97 @@ alignas(type) int var;
|
|||
REQUIRE(*args == '\0');
|
||||
};
|
||||
|
||||
auto count
|
||||
= test_visit<cpp_function>(*file,
|
||||
[&](const cpp_entity& e) {
|
||||
auto& attributes = e.attributes();
|
||||
REQUIRE(attributes.size() >= 1u);
|
||||
auto& attr = attributes.front();
|
||||
auto count = test_visit<cpp_function>(
|
||||
*file,
|
||||
[&](const cpp_entity& e) {
|
||||
auto& attributes = e.attributes();
|
||||
REQUIRE(attributes.size() >= 1u);
|
||||
auto& attr = attributes.front();
|
||||
|
||||
if (e.name() == "a" || e.name() == "b")
|
||||
{
|
||||
REQUIRE(attributes.size() == 2u);
|
||||
REQUIRE(has_attribute(e, "attribute1"));
|
||||
REQUIRE(has_attribute(e, "attribute2"));
|
||||
check_attribute(attr, "attribute1", type_safe::nullopt,
|
||||
false, "", cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[1u], "attribute2",
|
||||
type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
}
|
||||
else if (e.name() == "c")
|
||||
check_attribute(attr, "variadic", type_safe::nullopt,
|
||||
true, "", cpp_attribute_kind::unknown);
|
||||
else if (e.name() == "d")
|
||||
{
|
||||
REQUIRE(has_attribute(e, "ns::attribute"));
|
||||
check_attribute(attr, "attribute", "ns", false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
}
|
||||
else if (e.name() == "e")
|
||||
check_attribute(attr, "attribute", type_safe::nullopt,
|
||||
false, R"(arg1,arg2,+(){},42,"Hello!")",
|
||||
cpp_attribute_kind::unknown);
|
||||
else if (e.name() == "f")
|
||||
{
|
||||
REQUIRE(attributes.size() == 2u);
|
||||
check_attribute(attr, "attribute", "ns", false,
|
||||
"+,-,0 4", cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[1u], "other_attribute",
|
||||
type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
}
|
||||
else if (e.name() == "g")
|
||||
{
|
||||
REQUIRE(
|
||||
has_attribute(e, cpp_attribute_kind::deprecated));
|
||||
check_attribute(attr, "deprecated", type_safe::nullopt,
|
||||
false, "",
|
||||
cpp_attribute_kind::deprecated);
|
||||
}
|
||||
else if (e.name() == "h")
|
||||
check_attribute(attr, "maybe_unused", type_safe::nullopt,
|
||||
false, "",
|
||||
cpp_attribute_kind::maybe_unused);
|
||||
else if (e.name() == "i")
|
||||
check_attribute(attr, "nodiscard", type_safe::nullopt,
|
||||
false, "",
|
||||
cpp_attribute_kind::nodiscard);
|
||||
else if (e.name() == "j")
|
||||
check_attribute(attr, "noreturn", type_safe::nullopt,
|
||||
false, "", cpp_attribute_kind::noreturn);
|
||||
else if (e.name() == "k")
|
||||
check_attribute(attr, "const", type_safe::nullopt, false,
|
||||
"", cpp_attribute_kind::unknown);
|
||||
else if (e.name() == "l")
|
||||
{
|
||||
REQUIRE_NOTHROW(attributes.size() == 3);
|
||||
check_attribute(attributes[0], "a", type_safe::nullopt,
|
||||
false, "", cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[1], "b", type_safe::nullopt,
|
||||
false, "", cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[2], "c", type_safe::nullopt,
|
||||
false, "", cpp_attribute_kind::unknown);
|
||||
}
|
||||
},
|
||||
false);
|
||||
if (e.name() == "a" || e.name() == "b")
|
||||
{
|
||||
REQUIRE(attributes.size() == 2u);
|
||||
REQUIRE(has_attribute(e, "attribute1"));
|
||||
REQUIRE(has_attribute(e, "attribute2"));
|
||||
check_attribute(attr, "attribute1", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[1u], "attribute2", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
}
|
||||
else if (e.name() == "c")
|
||||
check_attribute(attr, "variadic", type_safe::nullopt, true, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
else if (e.name() == "d")
|
||||
{
|
||||
REQUIRE(has_attribute(e, "ns::attribute"));
|
||||
check_attribute(attr, "attribute", "ns", false, "", cpp_attribute_kind::unknown);
|
||||
}
|
||||
else if (e.name() == "e")
|
||||
check_attribute(attr, "attribute", type_safe::nullopt, false,
|
||||
R"(arg1,arg2,+(){},42,"Hello!")", cpp_attribute_kind::unknown);
|
||||
else if (e.name() == "f")
|
||||
{
|
||||
REQUIRE(attributes.size() == 2u);
|
||||
check_attribute(attr, "attribute", "ns", false, "+,-,0 4",
|
||||
cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[1u], "other_attribute", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
}
|
||||
else if (e.name() == "g")
|
||||
{
|
||||
REQUIRE(has_attribute(e, cpp_attribute_kind::deprecated));
|
||||
check_attribute(attr, "deprecated", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::deprecated);
|
||||
}
|
||||
else if (e.name() == "h")
|
||||
check_attribute(attr, "maybe_unused", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::maybe_unused);
|
||||
else if (e.name() == "i")
|
||||
check_attribute(attr, "nodiscard", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::nodiscard);
|
||||
else if (e.name() == "j")
|
||||
check_attribute(attr, "noreturn", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::noreturn);
|
||||
else if (e.name() == "k")
|
||||
check_attribute(attr, "const", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
else if (e.name() == "l")
|
||||
{
|
||||
REQUIRE_NOTHROW(attributes.size() == 3);
|
||||
check_attribute(attributes[0], "a", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[1], "b", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
check_attribute(attributes[2], "c", type_safe::nullopt, false, "",
|
||||
cpp_attribute_kind::unknown);
|
||||
}
|
||||
},
|
||||
false);
|
||||
REQUIRE(count == 11);
|
||||
|
||||
count = test_visit<cpp_class>(*file,
|
||||
[&](const cpp_entity& e) {
|
||||
auto& attributes = e.attributes();
|
||||
REQUIRE(attributes.size() == 1u);
|
||||
auto& attr = attributes.front();
|
||||
check_attribute(attr, "alignas", type_safe::nullopt, false,
|
||||
"8", cpp_attribute_kind::alignas_);
|
||||
},
|
||||
false);
|
||||
count = test_visit<cpp_class>(
|
||||
*file,
|
||||
[&](const cpp_entity& e) {
|
||||
auto& attributes = e.attributes();
|
||||
REQUIRE(attributes.size() == 1u);
|
||||
auto& attr = attributes.front();
|
||||
check_attribute(attr, "alignas", type_safe::nullopt, false, "8",
|
||||
cpp_attribute_kind::alignas_);
|
||||
},
|
||||
false);
|
||||
REQUIRE(count == 1u);
|
||||
|
||||
count = test_visit<cpp_variable>(*file,
|
||||
[&](const cpp_entity& e) {
|
||||
auto& attributes = e.attributes();
|
||||
INFO(e.name());
|
||||
REQUIRE(attributes.size() == 1u);
|
||||
auto& attr = attributes.front();
|
||||
check_attribute(attr, "alignas", type_safe::nullopt, false,
|
||||
"type", cpp_attribute_kind::alignas_);
|
||||
},
|
||||
false);
|
||||
count = test_visit<cpp_variable>(
|
||||
*file,
|
||||
[&](const cpp_entity& e) {
|
||||
auto& attributes = e.attributes();
|
||||
INFO(e.name());
|
||||
REQUIRE(attributes.size() == 1u);
|
||||
auto& attr = attributes.front();
|
||||
check_attribute(attr, "alignas", type_safe::nullopt, false, "type",
|
||||
cpp_attribute_kind::alignas_);
|
||||
},
|
||||
false);
|
||||
REQUIRE(count == 1u);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_class.hpp>
|
||||
|
||||
|
|
@ -164,7 +163,7 @@ struct g
|
|||
REQUIRE(child.name() == "public");
|
||||
REQUIRE(child.kind() == cpp_entity_kind::access_specifier_t);
|
||||
REQUIRE(static_cast<const cpp_access_specifier&>(child).access_specifier()
|
||||
== cpp_public);
|
||||
== cpp_public);
|
||||
break;
|
||||
case 2:
|
||||
REQUIRE(child.name() == "m2");
|
||||
|
|
@ -173,13 +172,13 @@ struct g
|
|||
REQUIRE(child.name() == "private");
|
||||
REQUIRE(child.kind() == cpp_entity_kind::access_specifier_t);
|
||||
REQUIRE(static_cast<const cpp_access_specifier&>(child).access_specifier()
|
||||
== cpp_private);
|
||||
== cpp_private);
|
||||
break;
|
||||
case 4:
|
||||
REQUIRE(child.name() == "private");
|
||||
REQUIRE(child.kind() == cpp_entity_kind::access_specifier_t);
|
||||
REQUIRE(static_cast<const cpp_access_specifier&>(child).access_specifier()
|
||||
== cpp_private);
|
||||
== cpp_private);
|
||||
break;
|
||||
case 5:
|
||||
REQUIRE(child.name() == "m3");
|
||||
|
|
@ -188,7 +187,7 @@ struct g
|
|||
REQUIRE(child.name() == "protected");
|
||||
REQUIRE(child.kind() == cpp_entity_kind::access_specifier_t);
|
||||
REQUIRE(static_cast<const cpp_access_specifier&>(child).access_specifier()
|
||||
== cpp_protected);
|
||||
== cpp_protected);
|
||||
break;
|
||||
case 7:
|
||||
REQUIRE(child.name() == "m4");
|
||||
|
|
@ -218,8 +217,8 @@ struct g
|
|||
REQUIRE(!base.is_virtual());
|
||||
|
||||
REQUIRE(equal_types(idx, base.type(),
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "a"))));
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "a"))));
|
||||
}
|
||||
else if (base.name() == "d")
|
||||
{
|
||||
|
|
@ -227,8 +226,8 @@ struct g
|
|||
REQUIRE(!base.is_virtual());
|
||||
|
||||
REQUIRE(equal_types(idx, base.type(),
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "d"))));
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "d"))));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
@ -253,8 +252,8 @@ struct g
|
|||
REQUIRE(!base.is_virtual());
|
||||
|
||||
REQUIRE(equal_types(idx, base.type(),
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "ns::base"))));
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "ns::base"))));
|
||||
}
|
||||
else if (base.name() == "e")
|
||||
{
|
||||
|
|
@ -262,8 +261,8 @@ struct g
|
|||
REQUIRE(base.is_virtual());
|
||||
|
||||
REQUIRE(equal_types(idx, base.type(),
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "e"))));
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "e"))));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
@ -288,8 +287,8 @@ struct g
|
|||
REQUIRE(!base.is_virtual());
|
||||
|
||||
REQUIRE(equal_types(idx, base.type(),
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "ns::base"))));
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "ns::base"))));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_class_template.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_enum.hpp>
|
||||
|
||||
|
|
@ -81,9 +80,9 @@ enum ns::c : int {};
|
|||
{
|
||||
REQUIRE(expr.kind() == cpp_expression_kind::unexposed_t);
|
||||
REQUIRE(static_cast<const cpp_unexposed_expression&>(expr)
|
||||
.expression()
|
||||
.as_string()
|
||||
== "42");
|
||||
.expression()
|
||||
.as_string()
|
||||
== "42");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -99,8 +98,8 @@ enum ns::c : int {};
|
|||
auto& expr = val.value().value();
|
||||
REQUIRE(expr.kind() == cpp_expression_kind::unexposed_t);
|
||||
REQUIRE(
|
||||
static_cast<const cpp_unexposed_expression&>(expr).expression().as_string()
|
||||
== "a_a+2");
|
||||
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)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_friend.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_function.hpp>
|
||||
|
||||
|
|
@ -104,15 +103,15 @@ void n(int i = int());
|
|||
else if (param.name() == "b")
|
||||
{
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_float))));
|
||||
*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)),
|
||||
cpp_token_string::tokenize("nullptr"))));
|
||||
equal_expressions(param.default_value().value(),
|
||||
*cpp_unexposed_expression::
|
||||
build(cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_float)),
|
||||
cpp_token_string::tokenize("nullptr"))));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
@ -124,14 +123,14 @@ void n(int i = int());
|
|||
else if (func.name() == "c")
|
||||
{
|
||||
REQUIRE(
|
||||
equal_types(idx, func.return_type(),
|
||||
*cpp_reference_type::
|
||||
build(cpp_array_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_literal_expression::
|
||||
build(cpp_builtin_type::build(
|
||||
cpp_ulonglong),
|
||||
"10")),
|
||||
cpp_ref_lvalue)));
|
||||
equal_types(idx, func.return_type(),
|
||||
*cpp_reference_type::
|
||||
build(cpp_array_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_literal_expression::
|
||||
build(cpp_builtin_type::build(
|
||||
cpp_ulonglong),
|
||||
"10")),
|
||||
cpp_ref_lvalue)));
|
||||
REQUIRE(func.signature() == "(decltype(42),...)");
|
||||
|
||||
auto count = 0u;
|
||||
|
|
@ -140,10 +139,10 @@ void n(int i = int());
|
|||
if (param.name() == "a")
|
||||
{
|
||||
REQUIRE(equal_types(idx, param.type(),
|
||||
*cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::
|
||||
build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("42")))));
|
||||
*cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::
|
||||
build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("42")))));
|
||||
REQUIRE(!param.default_value());
|
||||
}
|
||||
else
|
||||
|
|
@ -166,10 +165,10 @@ void n(int i = int());
|
|||
REQUIRE(equal_types(idx, param.type(), *cpp_builtin_type::build(cpp_int)));
|
||||
REQUIRE(param.default_value());
|
||||
REQUIRE(equal_expressions(param.default_value().value(),
|
||||
*cpp_unexposed_expression::
|
||||
build(cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_int)),
|
||||
cpp_token_string::tokenize("int()"))));
|
||||
*cpp_unexposed_expression::
|
||||
build(cpp_pointer_type::build(
|
||||
cpp_builtin_type::build(cpp_int)),
|
||||
cpp_token_string::tokenize("int()"))));
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
|
@ -192,20 +191,20 @@ void n(int i = int());
|
|||
auto bool_t = cpp_builtin_type::build(cpp_bool);
|
||||
if (func.name() == "d")
|
||||
REQUIRE(
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_literal_expression::build(std::move(bool_t), "true")));
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*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),
|
||||
cpp_token_string::tokenize(
|
||||
"false"))));
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
cpp_token_string::tokenize(
|
||||
"false"))));
|
||||
else if (func.name() == "f")
|
||||
REQUIRE(
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
cpp_token_string::tokenize(
|
||||
"noexcept(d())"))));
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_unexposed_expression::build(std::move(bool_t),
|
||||
cpp_token_string::tokenize(
|
||||
"noexcept(d())"))));
|
||||
}
|
||||
else if (func.name() == "g" || func.name() == "h" || func.name() == "i"
|
||||
|| func.name() == "j")
|
||||
|
|
@ -259,8 +258,8 @@ void n(int i = int());
|
|||
else if (func.name() == "m")
|
||||
{
|
||||
REQUIRE(equal_types(idx, func.return_type(),
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "ns::m"))));
|
||||
*cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""), "ns::m"))));
|
||||
REQUIRE(count_children(func.parameters()) == 0u);
|
||||
REQUIRE(!func.is_variadic());
|
||||
REQUIRE(!func.noexcept_condition());
|
||||
|
|
@ -362,9 +361,9 @@ void foo::a() {}
|
|||
REQUIRE(equal_types(idx, func.return_type(), *cpp_builtin_type::build(cpp_int)));
|
||||
REQUIRE(func.noexcept_condition());
|
||||
REQUIRE(
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_literal_expression::build(cpp_builtin_type::build(cpp_bool),
|
||||
"true")));
|
||||
equal_expressions(func.noexcept_condition().value(),
|
||||
*cpp_literal_expression::build(cpp_builtin_type::build(cpp_bool),
|
||||
"true")));
|
||||
REQUIRE(!func.is_constexpr());
|
||||
REQUIRE(func.body_kind() == cpp_function_definition);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_function_template.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_language_linkage.hpp>
|
||||
|
||||
|
|
@ -57,23 +56,24 @@ enum f {};
|
|||
REQUIRE(count == 3u);
|
||||
|
||||
// check enums for their correct parent
|
||||
count = test_visit<cpp_enum>(*file,
|
||||
[&](const cpp_enum& e) {
|
||||
if (e.name() == "a")
|
||||
check_parent(e, "\"C\"", "a");
|
||||
else if (e.name() == "b")
|
||||
check_parent(e, "cpp_language_linkage.cpp", "b");
|
||||
else if (e.name() == "c")
|
||||
check_parent(e, "\"C++\"", "c");
|
||||
else if (e.name() == "d")
|
||||
check_parent(e, "\"C++\"", "d");
|
||||
else if (e.name() == "e")
|
||||
check_parent(e, "\"C++\"", "e");
|
||||
else if (e.name() == "f")
|
||||
check_parent(e, "cpp_language_linkage.cpp", "f");
|
||||
else
|
||||
REQUIRE(false);
|
||||
},
|
||||
false); // don't check code generation here
|
||||
count = test_visit<cpp_enum>(
|
||||
*file,
|
||||
[&](const cpp_enum& e) {
|
||||
if (e.name() == "a")
|
||||
check_parent(e, "\"C\"", "a");
|
||||
else if (e.name() == "b")
|
||||
check_parent(e, "cpp_language_linkage.cpp", "b");
|
||||
else if (e.name() == "c")
|
||||
check_parent(e, "\"C++\"", "c");
|
||||
else if (e.name() == "d")
|
||||
check_parent(e, "\"C++\"", "d");
|
||||
else if (e.name() == "e")
|
||||
check_parent(e, "\"C++\"", "e");
|
||||
else if (e.name() == "f")
|
||||
check_parent(e, "cpp_language_linkage.cpp", "f");
|
||||
else
|
||||
REQUIRE(false);
|
||||
},
|
||||
false); // don't check code generation here
|
||||
REQUIRE(count == 6u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "test_parser.hpp"
|
||||
#include <cppast/cpp_member_function.hpp>
|
||||
|
|
@ -213,8 +212,8 @@ struct foo
|
|||
{
|
||||
REQUIRE(op.name() == "operator int&");
|
||||
REQUIRE(equal_types(idx, op.return_type(),
|
||||
*cpp_reference_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_ref_lvalue)));
|
||||
*cpp_reference_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_ref_lvalue)));
|
||||
REQUIRE(op.cv_qualifier() == cpp_cv_none);
|
||||
REQUIRE(op.signature() == "()");
|
||||
}
|
||||
|
|
@ -324,9 +323,9 @@ foo<T>::foo(int) {}
|
|||
{
|
||||
REQUIRE(cont.noexcept_condition());
|
||||
REQUIRE(equal_expressions(cont.noexcept_condition().value(),
|
||||
*cpp_literal_expression::build(cpp_builtin_type::build(
|
||||
cpp_bool),
|
||||
"true")));
|
||||
*cpp_literal_expression::build(cpp_builtin_type::build(
|
||||
cpp_bool),
|
||||
"true")));
|
||||
REQUIRE(!cont.is_explicit());
|
||||
REQUIRE(!cont.is_constexpr());
|
||||
REQUIRE(cont.body_kind() == cpp_function_defaulted);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_member_variable.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_namespace.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_preprocessor.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_static_assert.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_template_parameter.hpp>
|
||||
|
||||
|
|
@ -35,71 +34,63 @@ 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 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);
|
||||
}
|
||||
|
||||
|
|
@ -121,71 +112,61 @@ 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),
|
||||
cpp_token_string::tokenize(
|
||||
"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::tokenize("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);
|
||||
}
|
||||
|
||||
|
|
@ -214,122 +195,109 @@ 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_token.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_type_alias.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/cpp_variable.hpp>
|
||||
|
||||
|
|
@ -98,18 +97,18 @@ int r[] = {0};
|
|||
check_variable(var, *int_type, nullptr, cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "b")
|
||||
check_variable(var, *cpp_builtin_type::build(cpp_ulonglong),
|
||||
// unexposed due to implicit cast, I think
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("42"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
// unexposed due to implicit cast, I think
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("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),
|
||||
cpp_token_string::tokenize(
|
||||
"3.f+0.14f"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_float),
|
||||
cpp_token_string::tokenize(
|
||||
"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);
|
||||
else if (var.name() == "e")
|
||||
|
|
@ -118,104 +117,104 @@ int r[] = {0};
|
|||
check_variable(var, *int_type, nullptr, cpp_storage_class_thread_local, false, false);
|
||||
else if (var.name() == "g")
|
||||
check_variable(var, *int_type, nullptr,
|
||||
cpp_storage_class_static | cpp_storage_class_thread_local, false, false);
|
||||
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),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("12"))),
|
||||
cpp_storage_class_none, true, false);
|
||||
*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),
|
||||
cpp_token_string::tokenize("12"))),
|
||||
cpp_storage_class_none, true, false);
|
||||
else if (var.name() == "i")
|
||||
{
|
||||
check_variable(var,
|
||||
*cpp_user_defined_type::build(cpp_type_ref(cpp_entity_id(""), "foo")),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
*cpp_user_defined_type::build(cpp_type_ref(cpp_entity_id(""), "foo")),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
return false; // can't check code here
|
||||
}
|
||||
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),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_user_defined_type::build(
|
||||
cpp_type_ref(cpp_entity_id(""),
|
||||
"bar")),
|
||||
cpp_token_string::tokenize(
|
||||
"bar()"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
*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")),
|
||||
cpp_token_string::tokenize(
|
||||
"bar()"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
return false;
|
||||
}
|
||||
else if (var.name() == "k")
|
||||
{
|
||||
check_variable(var,
|
||||
*cpp_user_defined_type::build(cpp_type_ref(cpp_entity_id(""), "baz")),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
*cpp_user_defined_type::build(cpp_type_ref(cpp_entity_id(""), "baz")),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
return false;
|
||||
}
|
||||
else if (var.name() == "l")
|
||||
{
|
||||
check_variable(var, *cpp_user_defined_type::build(cpp_type_ref(cpp_entity_id(""), "")),
|
||||
nullptr, cpp_storage_class_static, false, false);
|
||||
nullptr, cpp_storage_class_static, false, false);
|
||||
return false;
|
||||
}
|
||||
else if (var.name() == "m")
|
||||
check_variable(var, *cpp_auto_type::build(),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("128"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("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),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("m"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
*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),
|
||||
cpp_token_string::tokenize("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),
|
||||
cpp_token_string::tokenize("0"))),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
*cpp_decltype_type::build(
|
||||
cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("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),
|
||||
cpp_token_string::tokenize("o"))),
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
*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::tokenize("o"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
cpp_cv_const),
|
||||
cpp_ref_lvalue),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_token_string::tokenize("o"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "q")
|
||||
check_variable(var,
|
||||
*cpp_array_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_literal_expression::
|
||||
build(cpp_builtin_type::build(cpp_ulonglong),
|
||||
"42")),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
*cpp_array_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_literal_expression::
|
||||
build(cpp_builtin_type::build(cpp_ulonglong),
|
||||
"42")),
|
||||
nullptr, cpp_storage_class_none, false, false);
|
||||
else if (var.name() == "r")
|
||||
check_variable(var,
|
||||
*cpp_array_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_literal_expression::
|
||||
build(cpp_builtin_type::build(cpp_ulonglong),
|
||||
"1")),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_unexposed_type::build(""),
|
||||
cpp_token_string::tokenize("{0}"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
*cpp_array_type::build(cpp_builtin_type::build(cpp_int),
|
||||
cpp_literal_expression::
|
||||
build(cpp_builtin_type::build(cpp_ulonglong),
|
||||
"1")),
|
||||
type_safe::ref(
|
||||
*cpp_unexposed_expression::build(cpp_unexposed_type::build(""),
|
||||
cpp_token_string::tokenize("{0}"))),
|
||||
cpp_storage_class_none, false, false);
|
||||
else
|
||||
REQUIRE(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "test_parser.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cppast/parser.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Copyright (C) 2017-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#ifndef CPPAST_TEST_PARSER_HPP_INCLUDED
|
||||
#define CPPAST_TEST_PARSER_HPP_INCLUDED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue