From 62e571a4d69cc9e038de28ff41a4661bb94ebeeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Mon, 7 Feb 2022 20:43:22 +0100 Subject: [PATCH] Update copyright notices --- CMakeLists.txt | 4 +- example/CMakeLists.txt | 4 +- example/ast_printer.cpp | 5 +- example/comparison.cpp | 85 ++-- example/documentation_generator.cpp | 63 ++- example/enum_category.cpp | 116 +++-- example/enum_to_string.cpp | 91 ++-- example/example_parser.hpp | 8 +- example/serialization.cpp | 87 ++-- external/external.cmake | 2 +- include/cppast/code_generator.hpp | 5 +- include/cppast/compile_config.hpp | 7 +- include/cppast/cpp_alias_template.hpp | 5 +- include/cppast/cpp_array_type.hpp | 5 +- include/cppast/cpp_attribute.hpp | 5 +- include/cppast/cpp_class.hpp | 5 +- include/cppast/cpp_class_template.hpp | 5 +- include/cppast/cpp_decltype_type.hpp | 5 +- include/cppast/cpp_entity.hpp | 7 +- include/cppast/cpp_entity_container.hpp | 5 +- include/cppast/cpp_entity_index.hpp | 9 +- include/cppast/cpp_entity_kind.hpp | 7 +- include/cppast/cpp_entity_ref.hpp | 5 +- include/cppast/cpp_enum.hpp | 5 +- include/cppast/cpp_expression.hpp | 5 +- include/cppast/cpp_file.hpp | 5 +- include/cppast/cpp_forward_declarable.hpp | 5 +- include/cppast/cpp_friend.hpp | 5 +- include/cppast/cpp_function.hpp | 5 +- include/cppast/cpp_function_template.hpp | 5 +- include/cppast/cpp_function_type.hpp | 5 +- include/cppast/cpp_language_linkage.hpp | 5 +- include/cppast/cpp_member_function.hpp | 5 +- include/cppast/cpp_member_variable.hpp | 7 +- include/cppast/cpp_namespace.hpp | 5 +- include/cppast/cpp_preprocessor.hpp | 5 +- include/cppast/cpp_static_assert.hpp | 5 +- .../cppast/cpp_storage_class_specifiers.hpp | 5 +- include/cppast/cpp_template.hpp | 9 +- include/cppast/cpp_template_parameter.hpp | 5 +- include/cppast/cpp_token.hpp | 5 +- include/cppast/cpp_type.hpp | 5 +- include/cppast/cpp_type_alias.hpp | 5 +- include/cppast/cpp_variable.hpp | 5 +- include/cppast/cpp_variable_base.hpp | 5 +- include/cppast/cpp_variable_template.hpp | 5 +- include/cppast/cppast_fwd.hpp | 12 +- include/cppast/detail/assert.hpp | 5 +- include/cppast/detail/intrusive_list.hpp | 7 +- include/cppast/diagnostic.hpp | 5 +- include/cppast/diagnostic_logger.hpp | 5 +- include/cppast/libclang_parser.hpp | 5 +- include/cppast/parser.hpp | 5 +- include/cppast/visitor.hpp | 5 +- src/CMakeLists.txt | 4 +- src/code_generator.cpp | 14 +- src/cpp_alias_template.cpp | 5 +- src/cpp_attribute.cpp | 5 +- src/cpp_class.cpp | 5 +- src/cpp_class_template.cpp | 5 +- src/cpp_entity.cpp | 5 +- src/cpp_entity_index.cpp | 5 +- src/cpp_entity_kind.cpp | 5 +- src/cpp_enum.cpp | 5 +- src/cpp_expression.cpp | 5 +- src/cpp_file.cpp | 5 +- src/cpp_forward_declarable.cpp | 5 +- src/cpp_friend.cpp | 5 +- src/cpp_function.cpp | 5 +- src/cpp_function_template.cpp | 5 +- src/cpp_language_linkage.cpp | 5 +- src/cpp_member_function.cpp | 5 +- src/cpp_member_variable.cpp | 5 +- src/cpp_namespace.cpp | 5 +- src/cpp_preprocessor.cpp | 5 +- src/cpp_static_assert.cpp | 5 +- src/cpp_template_parameter.cpp | 5 +- src/cpp_token.cpp | 5 +- src/cpp_type.cpp | 5 +- src/cpp_type_alias.cpp | 5 +- src/cpp_variable.cpp | 5 +- src/cpp_variable_template.cpp | 5 +- src/diagnostic_logger.cpp | 5 +- src/libclang/class_parser.cpp | 5 +- src/libclang/cxtokenizer.cpp | 5 +- src/libclang/cxtokenizer.hpp | 5 +- src/libclang/debug_helper.cpp | 5 +- src/libclang/debug_helper.hpp | 5 +- src/libclang/enum_parser.cpp | 5 +- src/libclang/expression_parser.cpp | 5 +- src/libclang/friend_parser.cpp | 9 +- src/libclang/function_parser.cpp | 5 +- src/libclang/language_linkage_parser.cpp | 5 +- src/libclang/libclang_parser.cpp | 7 +- src/libclang/libclang_visitor.hpp | 5 +- src/libclang/namespace_parser.cpp | 5 +- src/libclang/parse_error.hpp | 5 +- src/libclang/parse_functions.cpp | 8 +- src/libclang/parse_functions.hpp | 5 +- src/libclang/preprocessor.cpp | 5 +- src/libclang/preprocessor.hpp | 5 +- src/libclang/raii_wrapper.hpp | 5 +- src/libclang/template_parser.cpp | 5 +- src/libclang/type_parser.cpp | 5 +- src/libclang/variable_parser.cpp | 5 +- src/visitor.cpp | 5 +- test/CMakeLists.txt | 4 +- test/code_generator.cpp | 5 +- test/cpp_alias_template.cpp | 5 +- test/cpp_attribute.cpp | 183 ++++---- test/cpp_class.cpp | 33 +- test/cpp_class_template.cpp | 5 +- test/cpp_enum.cpp | 15 +- test/cpp_friend.cpp | 5 +- test/cpp_function.cpp | 81 ++-- test/cpp_function_template.cpp | 5 +- test/cpp_language_linkage.cpp | 42 +- test/cpp_member_function.cpp | 15 +- test/cpp_member_variable.cpp | 5 +- test/cpp_namespace.cpp | 5 +- test/cpp_preprocessor.cpp | 5 +- test/cpp_static_assert.cpp | 5 +- test/cpp_template_parameter.cpp | 436 ++++++++---------- test/cpp_token.cpp | 5 +- test/cpp_type_alias.cpp | 5 +- test/cpp_variable.cpp | 151 +++--- test/integration.cpp | 5 +- test/libclang_parser.cpp | 5 +- test/parser.cpp | 5 +- test/test.cpp | 5 +- test/test_parser.hpp | 5 +- tool/CMakeLists.txt | 4 +- tool/main.cpp | 8 +- 133 files changed, 936 insertions(+), 1103 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b52906f..34e222d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -# Copyright (C) 2017-2018 Jonathan Müller -# 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. cmake_minimum_required(VERSION 3.11) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index ff1d2b8..1cdbb44 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,5 +1,5 @@ -# Copyright (C) 2017-2018 Jonathan Müller -# 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. function(_cppast_example name) diff --git a/example/ast_printer.cpp b/example/ast_printer.cpp index 3cb3509..445d101 100644 --- a/example/ast_printer.cpp +++ b/example/ast_printer.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 /// \file /// This is a very primitive version of the cppast tool. diff --git a/example/comparison.cpp b/example/comparison.cpp index d78b8af..349dfdb 100644 --- a/example/comparison.cpp +++ b/example/comparison.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 /// \file /// Generate equality comparisons. @@ -80,48 +79,46 @@ void generate_op_non_equal(std::ostream& out, const cppast::cpp_class& c) // generate comparison operators for all classes in the file void generate_comparison(const cppast::cpp_file& file) { - cppast::visit(file, - [](const cppast::cpp_entity& e) { - // only visit non-templated class definitions that have the attribute set - return (!cppast::is_templated(e) - && e.kind() == cppast::cpp_entity_kind::class_t - && cppast::is_definition(e) - && cppast::has_attribute(e, "generate::comparison")) - // or all namespaces - || e.kind() == cppast::cpp_entity_kind::namespace_t; - }, - [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { - if (e.kind() == cppast::cpp_entity_kind::class_t && !info.is_old_entity()) - { - // it is a new class - auto& class_ = static_cast(e); - auto& attribute - = cppast::has_attribute(e, "generate::comparison").value(); + cppast::visit( + file, + [](const cppast::cpp_entity& e) { + // only visit non-templated class definitions that have the attribute set + return (!cppast::is_templated(e) && e.kind() == cppast::cpp_entity_kind::class_t + && cppast::is_definition(e) && cppast::has_attribute(e, "generate::comparison")) + // or all namespaces + || e.kind() == cppast::cpp_entity_kind::namespace_t; + }, + [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { + if (e.kind() == cppast::cpp_entity_kind::class_t && !info.is_old_entity()) + { + // it is a new class + auto& class_ = static_cast(e); + auto& attribute = cppast::has_attribute(e, "generate::comparison").value(); - // generate requested operators - if (attribute.arguments()) - { - if (has_token(attribute.arguments().value(), "==")) - generate_op_equal(std::cout, class_); - if (has_token(attribute.arguments().value(), "!=")) - generate_op_non_equal(std::cout, class_); - } - else - { - generate_op_equal(std::cout, class_); - generate_op_non_equal(std::cout, class_); - } - } - else if (e.kind() == cppast::cpp_entity_kind::namespace_t) - { - if (info.event == cppast::visitor_info::container_entity_enter) - // open namespace - std::cout << "namespace " << e.name() << " {\n\n"; - else // if (info.event == cppast::visitor_info::container_entity_exit) - // close namespace - std::cout << "}\n"; - } - }); + // generate requested operators + if (attribute.arguments()) + { + if (has_token(attribute.arguments().value(), "==")) + generate_op_equal(std::cout, class_); + if (has_token(attribute.arguments().value(), "!=")) + generate_op_non_equal(std::cout, class_); + } + else + { + generate_op_equal(std::cout, class_); + generate_op_non_equal(std::cout, class_); + } + } + else if (e.kind() == cppast::cpp_entity_kind::namespace_t) + { + if (info.event == cppast::visitor_info::container_entity_enter) + // open namespace + std::cout << "namespace " << e.name() << " {\n\n"; + else // if (info.event == cppast::visitor_info::container_entity_exit) + // close namespace + std::cout << "}\n"; + } + }); } int main(int argc, char* argv[]) diff --git a/example/documentation_generator.cpp b/example/documentation_generator.cpp index 9cefa52..ae9b460 100644 --- a/example/documentation_generator.cpp +++ b/example/documentation_generator.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 /// \file /// A primitive documentation generator. @@ -120,39 +119,39 @@ std::string generate_synopsis(const cppast::cpp_entity& e) void generate_documentation(const cppast::cpp_file& file) { // visit each entity - cppast::visit(file, - [](const cppast::cpp_entity& e, cppast::cpp_access_specifier_kind access) { - if (is_excluded_documentation(e, access)) - // exclude this and all children - return cppast::visit_filter::exclude_and_children; - else if (cppast::is_templated(e) || cppast::is_friended(e)) - // continue on with children for a dummy entity - return cppast::visit_filter::exclude; - else - return cppast::visit_filter::include; - }, - [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { - if (info.is_old_entity()) - // already done - return; + cppast::visit( + file, + [](const cppast::cpp_entity& e, cppast::cpp_access_specifier_kind access) { + if (is_excluded_documentation(e, access)) + // exclude this and all children + return cppast::visit_filter::exclude_and_children; + else if (cppast::is_templated(e) || cppast::is_friended(e)) + // continue on with children for a dummy entity + return cppast::visit_filter::exclude; + else + return cppast::visit_filter::include; + }, + [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { + if (info.is_old_entity()) + // already done + return; - // print name - std::cout << "## " << cppast::to_string(e.kind()) << " '" << e.name() - << "'\n"; - std::cout << '\n'; + // print name + std::cout << "## " << cppast::to_string(e.kind()) << " '" << e.name() << "'\n"; + std::cout << '\n'; - // print synopsis - std::cout << "```\n"; - std::cout << generate_synopsis(e); - std::cout << "```\n\n"; + // print synopsis + std::cout << "```\n"; + std::cout << generate_synopsis(e); + std::cout << "```\n\n"; - // print documentation comment - if (e.comment()) - std::cout << e.comment().value() << '\n'; + // print documentation comment + if (e.comment()) + std::cout << e.comment().value() << '\n'; - // print separator - std::cout << "\n---\n\n"; - }); + // print separator + std::cout << "\n---\n\n"; + }); std::cout << "\n\n"; } diff --git a/example/enum_category.cpp b/example/enum_category.cpp index c1b13e0..07a2175 100644 --- a/example/enum_category.cpp +++ b/example/enum_category.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 /// \file /// Generates enum category functions. @@ -55,68 +54,67 @@ const cppast::cpp_enum& get_enum(const cppast::cpp_entity_index& index, // generates the function definitions void generate_enum_category(const cppast::cpp_entity_index& index, const cppast::cpp_file& file) { - cppast::visit(file, - [](const cppast::cpp_entity& e) { - // only visit function declarations that have the attribute set - return (e.kind() == cppast::cpp_entity_kind::function_t - && !cppast::is_definition(e) - && cppast::has_attribute(e, "generate::enum_category")) - // or all namespaces - || e.kind() == cppast::cpp_entity_kind::namespace_t; - }, - [&](const cppast::cpp_entity& e, const cppast::visitor_info& info) { - if (e.kind() == cppast::cpp_entity_kind::function_t) - { - // a new function, generate implementation - assert(info.is_new_entity()); + cppast::visit( + file, + [](const cppast::cpp_entity& e) { + // only visit function declarations that have the attribute set + return (e.kind() == cppast::cpp_entity_kind::function_t && !cppast::is_definition(e) + && cppast::has_attribute(e, "generate::enum_category")) + // or all namespaces + || e.kind() == cppast::cpp_entity_kind::namespace_t; + }, + [&](const cppast::cpp_entity& e, const cppast::visitor_info& info) { + if (e.kind() == cppast::cpp_entity_kind::function_t) + { + // a new function, generate implementation + assert(info.is_new_entity()); - auto category = cppast::has_attribute(e, "generate::enum_category") - .value() - .arguments() - .value() - .as_string(); + auto category = cppast::has_attribute(e, "generate::enum_category") + .value() + .arguments() + .value() + .as_string(); - auto& func = static_cast(e); - // return type must be bool - assert(func.return_type().kind() == cppast::cpp_type_kind::builtin_t - && static_cast(func.return_type()) - .builtin_type_kind() - == cppast::cpp_bool); + auto& func = static_cast(e); + // return type must be bool + assert(func.return_type().kind() == cppast::cpp_type_kind::builtin_t + && static_cast(func.return_type()) + .builtin_type_kind() + == cppast::cpp_bool); - // single parameter... - assert(std::next(func.parameters().begin()) == func.parameters().end()); - auto& param = *func.parameters().begin(); - auto& enum_ = get_enum(index, param); + // single parameter... + assert(std::next(func.parameters().begin()) == func.parameters().end()); + auto& param = *func.parameters().begin(); + auto& enum_ = get_enum(index, param); - // generate function definition - std::cout << "inline bool " << func.name() << "(" - << cppast::to_string(param.type()) << " e) {\n"; + // generate function definition + std::cout << "inline bool " << func.name() << "(" << cppast::to_string(param.type()) + << " e) {\n"; - // generate switch - std::cout << " switch (e) {\n"; - for (const auto& enumerator : enum_) - { - std::cout << " case " << enum_.name() << "::" << enumerator.name() - << ":\n"; - if (is_category(enumerator, category)) - std::cout << " return true;\n"; - else - std::cout << " return false;\n"; - } - std::cout << " }\n"; + // generate switch + std::cout << " switch (e) {\n"; + for (const auto& enumerator : enum_) + { + std::cout << " case " << enum_.name() << "::" << enumerator.name() << ":\n"; + if (is_category(enumerator, category)) + std::cout << " return true;\n"; + else + std::cout << " return false;\n"; + } + std::cout << " }\n"; - std::cout << "}\n\n"; - } - else if (e.kind() == cppast::cpp_entity_kind::namespace_t) - { - if (info.event == cppast::visitor_info::container_entity_enter) - // open namespace - std::cout << "namespace " << e.name() << " {\n\n"; - else // if (info.event == cppast::visitor_info::container_entity_exit) - // close namespace - std::cout << "}\n"; - } - }); + std::cout << "}\n\n"; + } + else if (e.kind() == cppast::cpp_entity_kind::namespace_t) + { + if (info.event == cppast::visitor_info::container_entity_enter) + // open namespace + std::cout << "namespace " << e.name() << " {\n\n"; + else // if (info.event == cppast::visitor_info::container_entity_exit) + // close namespace + std::cout << "}\n"; + } + }); } int main(int argc, char* argv[]) diff --git a/example/enum_to_string.cpp b/example/enum_to_string.cpp index e2d9725..0163d0a 100644 --- a/example/enum_to_string.cpp +++ b/example/enum_to_string.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 /// \file /// Generates enum `to_string()` code. @@ -17,55 +16,51 @@ void generate_to_string(const cppast::cpp_file& file) { - cppast::visit(file, - [](const cppast::cpp_entity& e) { - // only visit enum definitions that have the attribute set - return (e.kind() == cppast::cpp_entity_kind::enum_t - && cppast::is_definition(e) - && cppast::has_attribute(e, "generate::to_string")) - // or all namespaces - || e.kind() == cppast::cpp_entity_kind::namespace_t; - }, - [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { - if (e.kind() == cppast::cpp_entity_kind::enum_t && !info.is_old_entity()) - { - // a new enum, generate to string function - auto& enum_ = static_cast(e); + cppast::visit( + file, + [](const cppast::cpp_entity& e) { + // only visit enum definitions that have the attribute set + return (e.kind() == cppast::cpp_entity_kind::enum_t && cppast::is_definition(e) + && cppast::has_attribute(e, "generate::to_string")) + // or all namespaces + || e.kind() == cppast::cpp_entity_kind::namespace_t; + }, + [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { + if (e.kind() == cppast::cpp_entity_kind::enum_t && !info.is_old_entity()) + { + // a new enum, generate to string function + auto& enum_ = static_cast(e); - // write function header - std::cout << "inline const char* to_string(const " << enum_.name() - << "& e) {\n"; + // write function header + std::cout << "inline const char* to_string(const " << enum_.name() << "& e) {\n"; - // generate switch - std::cout << " switch (e) {\n"; - for (const auto& enumerator : enum_) - { - std::cout << " case " << enum_.name() << "::" << enumerator.name() - << ":\n"; + // generate switch + std::cout << " switch (e) {\n"; + for (const auto& enumerator : enum_) + { + std::cout << " case " << enum_.name() << "::" << enumerator.name() << ":\n"; - // attribute can be used to override the string - if (auto attr - = cppast::has_attribute(enumerator, "generate::to_string")) - std::cout << " return " - << attr.value().arguments().value().as_string() - << ";\n"; - else - std::cout << " return \"" << enumerator.name() << "\";\n"; - } - std::cout << " }\n"; + // attribute can be used to override the string + if (auto attr = cppast::has_attribute(enumerator, "generate::to_string")) + std::cout << " return " << attr.value().arguments().value().as_string() + << ";\n"; + else + std::cout << " return \"" << enumerator.name() << "\";\n"; + } + std::cout << " }\n"; - std::cout << "}\n\n"; - } - else if (e.kind() == cppast::cpp_entity_kind::namespace_t) - { - if (info.event == cppast::visitor_info::container_entity_enter) - // open namespace - std::cout << "namespace " << e.name() << " {\n\n"; - else // if (info.event == cppast::visitor_info::container_entity_exit) - // close namespace - std::cout << "}\n"; - } - }); + std::cout << "}\n\n"; + } + else if (e.kind() == cppast::cpp_entity_kind::namespace_t) + { + if (info.event == cppast::visitor_info::container_entity_enter) + // open namespace + std::cout << "namespace " << e.name() << " {\n\n"; + else // if (info.event == cppast::visitor_info::container_entity_exit) + // close namespace + std::cout << "}\n"; + } + }); } int main(int argc, char* argv[]) diff --git a/example/example_parser.hpp b/example/example_parser.hpp index 647375c..777615d 100644 --- a/example/example_parser.hpp +++ b/example/example_parser.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_EXAMPLE_PARSER_HPP_INCLUDED #define CPPAST_EXAMPLE_PARSER_HPP_INCLUDED @@ -13,7 +12,8 @@ // parses all files in that directory // and invokes the callback for each of them template -int example_main(int argc, char* argv[], const cppast::cpp_entity_index& index, Callback cb) try +int example_main(int argc, char* argv[], const cppast::cpp_entity_index& index, Callback cb) +try { if (argc != 2) { diff --git a/example/serialization.cpp b/example/serialization.cpp index cb7020c..90387ce 100644 --- a/example/serialization.cpp +++ b/example/serialization.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 /// \file /// Serialization code generation. @@ -69,52 +68,50 @@ void generate_serialize_member(std::ostream& out, const cppast::cpp_member_varia // generate serialization function void generate_serialize(const cppast::cpp_file& file) { - cppast::visit(file, - [](const cppast::cpp_entity& e) { - // only visit non-templated class definitions that have the attribute set - return (!cppast::is_templated(e) - && e.kind() == cppast::cpp_entity_kind::class_t - && cppast::is_definition(e) - && cppast::has_attribute(e, "generate::serialize")) - // or all namespaces - || e.kind() == cppast::cpp_entity_kind::namespace_t; - }, - [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { - if (e.kind() == cppast::cpp_entity_kind::class_t && !info.is_old_entity()) - { - auto& class_ = static_cast(e); + cppast::visit( + file, + [](const cppast::cpp_entity& e) { + // only visit non-templated class definitions that have the attribute set + return (!cppast::is_templated(e) && e.kind() == cppast::cpp_entity_kind::class_t + && cppast::is_definition(e) && cppast::has_attribute(e, "generate::serialize")) + // or all namespaces + || e.kind() == cppast::cpp_entity_kind::namespace_t; + }, + [](const cppast::cpp_entity& e, const cppast::visitor_info& info) { + if (e.kind() == cppast::cpp_entity_kind::class_t && !info.is_old_entity()) + { + auto& class_ = static_cast(e); - std::cout << "inline void serialize(const foo::serializer& s, const " - << class_.name() << "& obj) {\n"; + std::cout << "inline void serialize(const foo::serializer& s, const " + << class_.name() << "& obj) {\n"; - // serialize base classes - for (auto& base : class_.bases()) - if (!cppast::has_attribute(base, "generate::transient")) - std::cout << " serialize(s, static_cast(obj));\n"; + // serialize base classes + for (auto& base : class_.bases()) + if (!cppast::has_attribute(base, "generate::transient")) + std::cout << " serialize(s, static_cast(obj));\n"; - // serialize member variables - for (auto& member : class_) - { - if (member.kind() == cppast::cpp_entity_kind::member_variable_t) - generate_serialize_member(std::cout, - static_cast< - const cppast::cpp_member_variable&>( - member)); - } + // serialize member variables + for (auto& member : class_) + { + if (member.kind() == cppast::cpp_entity_kind::member_variable_t) + generate_serialize_member(std::cout, + static_cast( + member)); + } - std::cout << "}\n\n"; - } - else if (e.kind() == cppast::cpp_entity_kind::namespace_t) - { - if (info.event == cppast::visitor_info::container_entity_enter) - // open namespace - std::cout << "namespace " << e.name() << " {\n\n"; - else // if (info.event == cppast::visitor_info::container_entity_exit) - // close namespace - std::cout << "}\n"; - } - }); + std::cout << "}\n\n"; + } + else if (e.kind() == cppast::cpp_entity_kind::namespace_t) + { + if (info.event == cppast::visitor_info::container_entity_enter) + // open namespace + std::cout << "namespace " << e.name() << " {\n\n"; + else // if (info.event == cppast::visitor_info::container_entity_exit) + // close namespace + std::cout << "}\n"; + } + }); } int main(int argc, char* argv[]) diff --git a/external/external.cmake b/external/external.cmake index e89407c..c42f01e 100644 --- a/external/external.cmake +++ b/external/external.cmake @@ -1,5 +1,5 @@ # Copyright (C) 2017 Jonathan Müller -# This file is subject to the license terms in the LICENSE file +# SPDX-License-Identifier: MIT # found in the top-level directory of this distribution. include(FetchContent) diff --git a/include/cppast/code_generator.hpp b/include/cppast/code_generator.hpp index 8614f81..04ec2d7 100644 --- a/include/cppast/code_generator.hpp +++ b/include/cppast/code_generator.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CODE_GENERATOR_HPP_INCLUDED #define CPPAST_CODE_GENERATOR_HPP_INCLUDED diff --git a/include/cppast/compile_config.hpp b/include/cppast/compile_config.hpp index 66b1bac..565cb57 100644 --- a/include/cppast/compile_config.hpp +++ b/include/cppast/compile_config.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_COMPILE_CONFIG_HPP_INCLUDED #define CPPAST_COMPILE_CONFIG_HPP_INCLUDED @@ -11,8 +10,8 @@ #include #include -#include #include +#include namespace cppast { diff --git a/include/cppast/cpp_alias_template.hpp b/include/cppast/cpp_alias_template.hpp index 3845a67..48824ff 100644 --- a/include/cppast/cpp_alias_template.hpp +++ b/include/cppast/cpp_alias_template.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ALIAS_TEMPLATE_HPP_INCLUDED #define CPPAST_CPP_ALIAS_TEMPLATE_HPP_INCLUDED diff --git a/include/cppast/cpp_array_type.hpp b/include/cppast/cpp_array_type.hpp index 0f8a9be..dabe78e 100644 --- a/include/cppast/cpp_array_type.hpp +++ b/include/cppast/cpp_array_type.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ARRAY_TYPE_HPP_INCLUDED #define CPPAST_CPP_ARRAY_TYPE_HPP_INCLUDED diff --git a/include/cppast/cpp_attribute.hpp b/include/cppast/cpp_attribute.hpp index 4c288bd..a640be0 100644 --- a/include/cppast/cpp_attribute.hpp +++ b/include/cppast/cpp_attribute.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ATTRIBUTE_HPP_INCLUDED #define CPPAST_CPP_ATTRIBUTE_HPP_INCLUDED diff --git a/include/cppast/cpp_class.hpp b/include/cppast/cpp_class.hpp index c32a8c9..3d9f713 100644 --- a/include/cppast/cpp_class.hpp +++ b/include/cppast/cpp_class.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_CLASS_HPP_INCLUDED #define CPPAST_CPP_CLASS_HPP_INCLUDED diff --git a/include/cppast/cpp_class_template.hpp b/include/cppast/cpp_class_template.hpp index 0ec2114..8ae8f51 100644 --- a/include/cppast/cpp_class_template.hpp +++ b/include/cppast/cpp_class_template.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_CLASS_TEMPLATE_HPP_INCLUDED #define CPPAST_CPP_CLASS_TEMPLATE_HPP_INCLUDED diff --git a/include/cppast/cpp_decltype_type.hpp b/include/cppast/cpp_decltype_type.hpp index b7fdc17..eafffc4 100644 --- a/include/cppast/cpp_decltype_type.hpp +++ b/include/cppast/cpp_decltype_type.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_DECLTYPE_TYPE_HPP_INCLUDED #define CPPAST_CPP_DECLTYPE_TYPE_HPP_INCLUDED diff --git a/include/cppast/cpp_entity.hpp b/include/cppast/cpp_entity.hpp index 1764256..639c61b 100644 --- a/include/cppast/cpp_entity.hpp +++ b/include/cppast/cpp_entity.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ENTITY_HPP_INCLUDED #define CPPAST_CPP_ENTITY_HPP_INCLUDED @@ -151,7 +150,7 @@ public: { user_data_ = data; } - + /// \effects Creates it giving it the the name. cpp_entity(std::string name) : name_(std::move(name)), user_data_(nullptr) {} diff --git a/include/cppast/cpp_entity_container.hpp b/include/cppast/cpp_entity_container.hpp index 55f1bb4..7a0c7c4 100644 --- a/include/cppast/cpp_entity_container.hpp +++ b/include/cppast/cpp_entity_container.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ENTITY_CONTAINER_HPP_INCLUDED #define CPPAST_CPP_ENTITY_CONTAINER_HPP_INCLUDED diff --git a/include/cppast/cpp_entity_index.hpp b/include/cppast/cpp_entity_index.hpp index 0f13f7e..2b05fd1 100644 --- a/include/cppast/cpp_entity_index.hpp +++ b/include/cppast/cpp_entity_index.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ENTITY_INDEX_HPP_INCLUDED #define CPPAST_CPP_ENTITY_INDEX_HPP_INCLUDED @@ -104,8 +103,8 @@ public: /// \returns A [ts::optional_ref]() corresponding to the entity of the given /// [cppast::cpp_entity_id](). If no definition has been registered, it returns an empty /// optional. \notes This operation is thread safe. - type_safe::optional_ref lookup_definition(const cpp_entity_id& id) const - noexcept; + type_safe::optional_ref lookup_definition( + const cpp_entity_id& id) const noexcept; /// \returns A [ts::array_ref]() of references to all namespaces matching the given /// [cppast::cpp_entity_id](). If no namespace is found, it returns an empty array reference. diff --git a/include/cppast/cpp_entity_kind.hpp b/include/cppast/cpp_entity_kind.hpp index 520b5f1..c5d3449 100644 --- a/include/cppast/cpp_entity_kind.hpp +++ b/include/cppast/cpp_entity_kind.hpp @@ -1,12 +1,11 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ENTITY_KIND_HPP_INCLUDED #define CPPAST_CPP_ENTITY_KIND_HPP_INCLUDED -#include #include +#include namespace cppast { diff --git a/include/cppast/cpp_entity_ref.hpp b/include/cppast/cpp_entity_ref.hpp index b67be84..b2f4fd3 100644 --- a/include/cppast/cpp_entity_ref.hpp +++ b/include/cppast/cpp_entity_ref.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ENTITY_REF_HPP_INCLUDED #define CPPAST_CPP_ENTITY_REF_HPP_INCLUDED diff --git a/include/cppast/cpp_enum.hpp b/include/cppast/cpp_enum.hpp index 8d5b0fd..a7c5beb 100644 --- a/include/cppast/cpp_enum.hpp +++ b/include/cppast/cpp_enum.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_ENUM_HPP_INCLUDED #define CPPAST_CPP_ENUM_HPP_INCLUDED diff --git a/include/cppast/cpp_expression.hpp b/include/cppast/cpp_expression.hpp index 0917662..5286544 100644 --- a/include/cppast/cpp_expression.hpp +++ b/include/cppast/cpp_expression.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_EXPRESSION_HPP_INCLUDED #define CPPAST_CPP_EXPRESSION_HPP_INCLUDED diff --git a/include/cppast/cpp_file.hpp b/include/cppast/cpp_file.hpp index 261459e..65bf492 100644 --- a/include/cppast/cpp_file.hpp +++ b/include/cppast/cpp_file.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_FILE_HPP_INCLUDED #define CPPAST_CPP_FILE_HPP_INCLUDED diff --git a/include/cppast/cpp_forward_declarable.hpp b/include/cppast/cpp_forward_declarable.hpp index c236f32..668ef7a 100644 --- a/include/cppast/cpp_forward_declarable.hpp +++ b/include/cppast/cpp_forward_declarable.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_FORWARD_DECLARABLE_HPP_INCLUDED #define CPPAST_CPP_FORWARD_DECLARABLE_HPP_INCLUDED diff --git a/include/cppast/cpp_friend.hpp b/include/cppast/cpp_friend.hpp index c62972c..e6c95cc 100644 --- a/include/cppast/cpp_friend.hpp +++ b/include/cppast/cpp_friend.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_FRIEND_HPP_INCLUDED #define CPPAST_CPP_FRIEND_HPP_INCLUDED diff --git a/include/cppast/cpp_function.hpp b/include/cppast/cpp_function.hpp index 250c9e2..9c0fce5 100644 --- a/include/cppast/cpp_function.hpp +++ b/include/cppast/cpp_function.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_FUNCTION_HPP_INCLUDED #define CPPAST_CPP_FUNCTION_HPP_INCLUDED diff --git a/include/cppast/cpp_function_template.hpp b/include/cppast/cpp_function_template.hpp index beb1823..9f953ac 100644 --- a/include/cppast/cpp_function_template.hpp +++ b/include/cppast/cpp_function_template.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_FUNCTION_TEMPLATE_HPP_INCLUDED #define CPPAST_CPP_FUNCTION_TEMPLATE_HPP_INCLUDED diff --git a/include/cppast/cpp_function_type.hpp b/include/cppast/cpp_function_type.hpp index 63aae37..b0f5fe5 100644 --- a/include/cppast/cpp_function_type.hpp +++ b/include/cppast/cpp_function_type.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_FUNCTION_TYPE_HPP_INCLUDED #define CPPAST_CPP_FUNCTION_TYPE_HPP_INCLUDED diff --git a/include/cppast/cpp_language_linkage.hpp b/include/cppast/cpp_language_linkage.hpp index 7135458..99e8834 100644 --- a/include/cppast/cpp_language_linkage.hpp +++ b/include/cppast/cpp_language_linkage.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_LANGUAGE_LINKAGE_HPP_INCLUDED #define CPPAST_CPP_LANGUAGE_LINKAGE_HPP_INCLUDED diff --git a/include/cppast/cpp_member_function.hpp b/include/cppast/cpp_member_function.hpp index 7d96007..97daf85 100644 --- a/include/cppast/cpp_member_function.hpp +++ b/include/cppast/cpp_member_function.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_MEMBER_FUNCTION_HPP_INCLUDED #define CPPAST_CPP_MEMBER_FUNCTION_HPP_INCLUDED diff --git a/include/cppast/cpp_member_variable.hpp b/include/cppast/cpp_member_variable.hpp index 13c7abe..ca988f8 100644 --- a/include/cppast/cpp_member_variable.hpp +++ b/include/cppast/cpp_member_variable.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_MEMBER_VARIABLE_HPP_INCLUDED #define CPPAST_CPP_MEMBER_VARIABLE_HPP_INCLUDED @@ -19,7 +18,7 @@ public: { return mutable_; } - + cpp_member_variable_base(std::string name, std::unique_ptr type, std::unique_ptr def, bool is_mutable) : cpp_entity(std::move(name)), cpp_variable_base(std::move(type), std::move(def)), diff --git a/include/cppast/cpp_namespace.hpp b/include/cppast/cpp_namespace.hpp index 9d81cf8..73b3061 100644 --- a/include/cppast/cpp_namespace.hpp +++ b/include/cppast/cpp_namespace.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_NAMESPACE_HPP_INCLUDED #define CPPAST_CPP_NAMESPACE_HPP_INCLUDED diff --git a/include/cppast/cpp_preprocessor.hpp b/include/cppast/cpp_preprocessor.hpp index 0a60554..7b9afac 100644 --- a/include/cppast/cpp_preprocessor.hpp +++ b/include/cppast/cpp_preprocessor.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_PREPROCESSOR_HPP_INCLUDED #define CPPAST_CPP_PREPROCESSOR_HPP_INCLUDED diff --git a/include/cppast/cpp_static_assert.hpp b/include/cppast/cpp_static_assert.hpp index 44fe3f8..f00d97a 100644 --- a/include/cppast/cpp_static_assert.hpp +++ b/include/cppast/cpp_static_assert.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_STATIC_ASSERT_HPP_INCLUDED #define CPPAST_CPP_STATIC_ASSERT_HPP_INCLUDED diff --git a/include/cppast/cpp_storage_class_specifiers.hpp b/include/cppast/cpp_storage_class_specifiers.hpp index 8f9a775..697f85d 100644 --- a/include/cppast/cpp_storage_class_specifiers.hpp +++ b/include/cppast/cpp_storage_class_specifiers.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_STORAGE_CLASS_SPECIFIERS_HPP_INCLUDED #define CPPAST_CPP_STORAGE_CLASS_SPECIFIERS_HPP_INCLUDED diff --git a/include/cppast/cpp_template.hpp b/include/cppast/cpp_template.hpp index 4a80202..4b0b60d 100644 --- a/include/cppast/cpp_template.hpp +++ b/include/cppast/cpp_template.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_TEMPLATE_HPP_INCLUDED #define CPPAST_CPP_TEMPLATE_HPP_INCLUDED @@ -143,8 +142,8 @@ public: /// \returns An array ref to the [cppast::cpp_template_argument](), if there are any. /// \requires The arguments are exposed, i.e. `arguments_exposed()` returns `true`. - type_safe::optional> arguments() const - noexcept + type_safe::optional> arguments() + const noexcept { auto& vec = arguments_.value(type_safe::variant_type>{}); if (vec.empty()) diff --git a/include/cppast/cpp_template_parameter.hpp b/include/cppast/cpp_template_parameter.hpp index 99c6a8f..c3ef62a 100644 --- a/include/cppast/cpp_template_parameter.hpp +++ b/include/cppast/cpp_template_parameter.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_TEMPLATE_PARAMETER_HPP_INCLUDED #define CPPAST_CPP_TEMPLATE_PARAMETER_HPP_INCLUDED diff --git a/include/cppast/cpp_token.hpp b/include/cppast/cpp_token.hpp index f0a1d29..783464f 100644 --- a/include/cppast/cpp_token.hpp +++ b/include/cppast/cpp_token.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_TOKEN_HPP_INCLUDED #define CPPAST_CPP_TOKEN_HPP_INCLUDED diff --git a/include/cppast/cpp_type.hpp b/include/cppast/cpp_type.hpp index 5accc42..d275614 100644 --- a/include/cppast/cpp_type.hpp +++ b/include/cppast/cpp_type.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_TYPE_HPP_INCLUDED #define CPPAST_CPP_TYPE_HPP_INCLUDED diff --git a/include/cppast/cpp_type_alias.hpp b/include/cppast/cpp_type_alias.hpp index c582958..637e9b4 100644 --- a/include/cppast/cpp_type_alias.hpp +++ b/include/cppast/cpp_type_alias.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_TYPE_ALIAS_HPP_INCLUDED #define CPPAST_CPP_TYPE_ALIAS_HPP_INCLUDED diff --git a/include/cppast/cpp_variable.hpp b/include/cppast/cpp_variable.hpp index 2d5b372..7cb105b 100644 --- a/include/cppast/cpp_variable.hpp +++ b/include/cppast/cpp_variable.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_VARIABLE_HPP_INCLUDED #define CPPAST_CPP_VARIABLE_HPP_INCLUDED diff --git a/include/cppast/cpp_variable_base.hpp b/include/cppast/cpp_variable_base.hpp index 96c5ea7..d39e74a 100644 --- a/include/cppast/cpp_variable_base.hpp +++ b/include/cppast/cpp_variable_base.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_VARIABLE_BASE_HPP_INCLUDED #define CPPAST_CPP_VARIABLE_BASE_HPP_INCLUDED diff --git a/include/cppast/cpp_variable_template.hpp b/include/cppast/cpp_variable_template.hpp index 6e75fec..b89d1a6 100644 --- a/include/cppast/cpp_variable_template.hpp +++ b/include/cppast/cpp_variable_template.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CPP_VARIABLE_TEMPLATE_HPP_INCLUDED #define CPPAST_CPP_VARIABLE_TEMPLATE_HPP_INCLUDED diff --git a/include/cppast/cppast_fwd.hpp b/include/cppast/cppast_fwd.hpp index d8a40d8..2f77776 100644 --- a/include/cppast/cppast_fwd.hpp +++ b/include/cppast/cppast_fwd.hpp @@ -1,6 +1,5 @@ // Copyright (C) 2021 Julian Rüth -// This file is subject to the license terms in the LICENSE file -// found in the top-level directory of this distribution. +// SPDX-License-Identifier: MIT #ifndef CPPAST_FORWARD_HPP_INCLUDED #define CPPAST_FORWARD_HPP_INCLUDED @@ -118,9 +117,12 @@ struct source_location; struct visitor_info; struct whitespace_t; -template class cpp_entity_container; -template class simple_file_parser; -template class basic_cpp_entity_ref; +template +class cpp_entity_container; +template +class simple_file_parser; +template +class basic_cpp_entity_ref; } // namespace cppast diff --git a/include/cppast/detail/assert.hpp b/include/cppast/detail/assert.hpp index 7d6cd03..dcced03 100644 --- a/include/cppast/detail/assert.hpp +++ b/include/cppast/detail/assert.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_ASSERT_HPP_INCLUDED #define CPPAST_ASSERT_HPP_INCLUDED diff --git a/include/cppast/detail/intrusive_list.hpp b/include/cppast/detail/intrusive_list.hpp index 7ddad7d..ac83239 100644 --- a/include/cppast/detail/intrusive_list.hpp +++ b/include/cppast/detail/intrusive_list.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_INTRUSIVE_LIST_HPP_INCLUDED #define CPPAST_INTRUSIVE_LIST_HPP_INCLUDED @@ -10,8 +9,8 @@ #include -#include #include +#include namespace cppast { diff --git a/include/cppast/diagnostic.hpp b/include/cppast/diagnostic.hpp index f85933b..f84b329 100644 --- a/include/cppast/diagnostic.hpp +++ b/include/cppast/diagnostic.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_DIAGNOSTIC_HPP_INCLUDED #define CPPAST_DIAGNOSTIC_HPP_INCLUDED diff --git a/include/cppast/diagnostic_logger.hpp b/include/cppast/diagnostic_logger.hpp index 0cf02f1..94fab6a 100644 --- a/include/cppast/diagnostic_logger.hpp +++ b/include/cppast/diagnostic_logger.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_DIAGNOSTIC_LOGGER_HPP_INCLUDED #define CPPAST_DIAGNOSTIC_LOGGER_HPP_INCLUDED diff --git a/include/cppast/libclang_parser.hpp b/include/cppast/libclang_parser.hpp index 134e7c7..c96ae18 100644 --- a/include/cppast/libclang_parser.hpp +++ b/include/cppast/libclang_parser.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_LIBCLANG_PARSER_HPP_INCLUDED #define CPPAST_LIBCLANG_PARSER_HPP_INCLUDED diff --git a/include/cppast/parser.hpp b/include/cppast/parser.hpp index e6c2ed6..5a07c0f 100644 --- a/include/cppast/parser.hpp +++ b/include/cppast/parser.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_PARSER_HPP_INCLUDED #define CPPAST_PARSER_HPP_INCLUDED diff --git a/include/cppast/visitor.hpp b/include/cppast/visitor.hpp index 1e75039..8541bac 100644 --- a/include/cppast/visitor.hpp +++ b/include/cppast/visitor.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_VISITOR_HPP_INCLUDED #define CPPAST_VISITOR_HPP_INCLUDED diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5062670..2fa30b0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ -# Copyright (C) 2017-2018 Jonathan Müller -# 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. set(detail_header diff --git a/src/code_generator.cpp b/src/code_generator.cpp index 1c7d717..20f264c 100644 --- a/src/code_generator.cpp +++ b/src/code_generator.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -292,11 +291,10 @@ bool generate_enum(code_generator& generator, const cpp_enum& e, output << opening_brace; output.indent(); - auto need_sep = write_container(output, e, - [](const code_generator::output& out) { - out << punctuation(",") << newl; - }, - cur_access); + auto need_sep = write_container( + output, e, + [](const code_generator::output& out) { out << punctuation(",") << newl; }, + cur_access); if (need_sep) output << newl; diff --git a/src/cpp_alias_template.cpp b/src/cpp_alias_template.cpp index e5c60f8..2ee1df8 100644 --- a/src/cpp_alias_template.cpp +++ b/src/cpp_alias_template.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_attribute.cpp b/src/cpp_attribute.cpp index 22a4b34..2333d55 100644 --- a/src/cpp_attribute.cpp +++ b/src/cpp_attribute.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_class.cpp b/src/cpp_class.cpp index 1be6b66..56659d2 100644 --- a/src/cpp_class.cpp +++ b/src/cpp_class.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_class_template.cpp b/src/cpp_class_template.cpp index d32120a..2274ee5 100644 --- a/src/cpp_class_template.cpp +++ b/src/cpp_class_template.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_entity.cpp b/src/cpp_entity.cpp index 6053c09..1aeb02b 100644 --- a/src/cpp_entity.cpp +++ b/src/cpp_entity.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_entity_index.cpp b/src/cpp_entity_index.cpp index 6278f22..e802b9b 100644 --- a/src/cpp_entity_index.cpp +++ b/src/cpp_entity_index.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_entity_kind.cpp b/src/cpp_entity_kind.cpp index 01364da..7da8500 100644 --- a/src/cpp_entity_kind.cpp +++ b/src/cpp_entity_kind.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_enum.cpp b/src/cpp_enum.cpp index 22ef7ad..b8a8eae 100644 --- a/src/cpp_enum.cpp +++ b/src/cpp_enum.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_expression.cpp b/src/cpp_expression.cpp index b2f9c1b..e65161a 100644 --- a/src/cpp_expression.cpp +++ b/src/cpp_expression.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_file.cpp b/src/cpp_file.cpp index 8bca37c..47eb158 100644 --- a/src/cpp_file.cpp +++ b/src/cpp_file.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_forward_declarable.cpp b/src/cpp_forward_declarable.cpp index c0054e2..40c6255 100644 --- a/src/cpp_forward_declarable.cpp +++ b/src/cpp_forward_declarable.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_friend.cpp b/src/cpp_friend.cpp index 70ac40e..f027db1 100644 --- a/src/cpp_friend.cpp +++ b/src/cpp_friend.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_function.cpp b/src/cpp_function.cpp index 47ffb77..d565ca8 100644 --- a/src/cpp_function.cpp +++ b/src/cpp_function.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_function_template.cpp b/src/cpp_function_template.cpp index 1767e35..c310d88 100644 --- a/src/cpp_function_template.cpp +++ b/src/cpp_function_template.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_language_linkage.cpp b/src/cpp_language_linkage.cpp index 051ce01..a05daf9 100644 --- a/src/cpp_language_linkage.cpp +++ b/src/cpp_language_linkage.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_member_function.cpp b/src/cpp_member_function.cpp index aa54cf6..346a7b2 100644 --- a/src/cpp_member_function.cpp +++ b/src/cpp_member_function.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_member_variable.cpp b/src/cpp_member_variable.cpp index 4e537af..f2495f7 100644 --- a/src/cpp_member_variable.cpp +++ b/src/cpp_member_variable.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_namespace.cpp b/src/cpp_namespace.cpp index c44c151..bff8141 100644 --- a/src/cpp_namespace.cpp +++ b/src/cpp_namespace.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_preprocessor.cpp b/src/cpp_preprocessor.cpp index 801bd7d..716c181 100644 --- a/src/cpp_preprocessor.cpp +++ b/src/cpp_preprocessor.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_static_assert.cpp b/src/cpp_static_assert.cpp index 7090d56..8a501a0 100644 --- a/src/cpp_static_assert.cpp +++ b/src/cpp_static_assert.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_template_parameter.cpp b/src/cpp_template_parameter.cpp index 71639a9..aae4a2f 100644 --- a/src/cpp_template_parameter.cpp +++ b/src/cpp_template_parameter.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_token.cpp b/src/cpp_token.cpp index 5a4ab34..3094570 100644 --- a/src/cpp_token.cpp +++ b/src/cpp_token.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_type.cpp b/src/cpp_type.cpp index c8d2ea3..f11e72e 100644 --- a/src/cpp_type.cpp +++ b/src/cpp_type.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_type_alias.cpp b/src/cpp_type_alias.cpp index b0b088a..fd45d85 100644 --- a/src/cpp_type_alias.cpp +++ b/src/cpp_type_alias.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_variable.cpp b/src/cpp_variable.cpp index 2a21743..0dad088 100644 --- a/src/cpp_variable.cpp +++ b/src/cpp_variable.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/cpp_variable_template.cpp b/src/cpp_variable_template.cpp index 92c598e..7f992f2 100644 --- a/src/cpp_variable_template.cpp +++ b/src/cpp_variable_template.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/diagnostic_logger.cpp b/src/diagnostic_logger.cpp index 56fda11..c828223 100644 --- a/src/diagnostic_logger.cpp +++ b/src/diagnostic_logger.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/libclang/class_parser.cpp b/src/libclang/class_parser.cpp index 5f76772..af81632 100644 --- a/src/libclang/class_parser.cpp +++ b/src/libclang/class_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 #include diff --git a/src/libclang/cxtokenizer.cpp b/src/libclang/cxtokenizer.cpp index 7131cc2..022c839 100644 --- a/src/libclang/cxtokenizer.cpp +++ b/src/libclang/cxtokenizer.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "cxtokenizer.hpp" diff --git a/src/libclang/cxtokenizer.hpp b/src/libclang/cxtokenizer.hpp index 91153d4..03e79e2 100644 --- a/src/libclang/cxtokenizer.hpp +++ b/src/libclang/cxtokenizer.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_CXTOKENIZER_HPP_INCLUDED #define CPPAST_CXTOKENIZER_HPP_INCLUDED diff --git a/src/libclang/debug_helper.cpp b/src/libclang/debug_helper.cpp index 3c65e0f..ec1a8ec 100644 --- a/src/libclang/debug_helper.cpp +++ b/src/libclang/debug_helper.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "debug_helper.hpp" diff --git a/src/libclang/debug_helper.hpp b/src/libclang/debug_helper.hpp index eda7de1..9709bab 100644 --- a/src/libclang/debug_helper.hpp +++ b/src/libclang/debug_helper.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_DEBUG_HELPER_HPP_INCLUDED #define CPPAST_DEBUG_HELPER_HPP_INCLUDED diff --git a/src/libclang/enum_parser.cpp b/src/libclang/enum_parser.cpp index cb219fa..8533eca 100644 --- a/src/libclang/enum_parser.cpp +++ b/src/libclang/enum_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/libclang/expression_parser.cpp b/src/libclang/expression_parser.cpp index bb6406a..ab84dca 100644 --- a/src/libclang/expression_parser.cpp +++ b/src/libclang/expression_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/src/libclang/friend_parser.cpp b/src/libclang/friend_parser.cpp index 7d01e56..fa01670 100644 --- a/src/libclang/friend_parser.cpp +++ b/src/libclang/friend_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -45,8 +44,8 @@ std::unique_ptr detail::parse_cpp_friend(const detail::parse_context // as then the class name would be wrong auto name = detail::get_cursor_name(referenced); type = cpp_user_defined_type::build( - cpp_type_ref(detail::get_entity_id(referenced), - namespace_str + "::" + name.c_str())); + cpp_type_ref(detail::get_entity_id(referenced), + namespace_str + "::" + name.c_str())); } else { diff --git a/src/libclang/function_parser.cpp b/src/libclang/function_parser.cpp index 20975d2..5cff0cc 100644 --- a/src/libclang/function_parser.cpp +++ b/src/libclang/function_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 #include diff --git a/src/libclang/language_linkage_parser.cpp b/src/libclang/language_linkage_parser.cpp index 3f37514..a267bce 100644 --- a/src/libclang/language_linkage_parser.cpp +++ b/src/libclang/language_linkage_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "parse_functions.hpp" diff --git a/src/libclang/libclang_parser.cpp b/src/libclang/libclang_parser.cpp index 8179a63..b45290b 100644 --- a/src/libclang/libclang_parser.cpp +++ b/src/libclang/libclang_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -494,7 +493,7 @@ namespace std::vector get_arguments(const libclang_compile_config& config) { std::vector args - // TODO: Why? and Why? + // TODO: Why? and Why? = {"-x", "c++", "-I."}; // force C++ and enable current directory for include search for (auto& flag : detail::libclang_compile_config_access::flags(config)) args.push_back(flag.c_str()); diff --git a/src/libclang/libclang_visitor.hpp b/src/libclang/libclang_visitor.hpp index 907d89b..2eccc6d 100644 --- a/src/libclang/libclang_visitor.hpp +++ b/src/libclang/libclang_visitor.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_LIBCLANG_VISITOR_HPP_INCLUDED #define CPPAST_LIBCLANG_VISITOR_HPP_INCLUDED diff --git a/src/libclang/namespace_parser.cpp b/src/libclang/namespace_parser.cpp index 7c837bc..e847366 100644 --- a/src/libclang/namespace_parser.cpp +++ b/src/libclang/namespace_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "parse_functions.hpp" diff --git a/src/libclang/parse_error.hpp b/src/libclang/parse_error.hpp index a072a39..7a93144 100644 --- a/src/libclang/parse_error.hpp +++ b/src/libclang/parse_error.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_PARSE_ERROR_HPP_INCLUDED #define CPPAST_PARSE_ERROR_HPP_INCLUDED diff --git a/src/libclang/parse_functions.cpp b/src/libclang/parse_functions.cpp index 0112aca..39e9aa9 100644 --- a/src/libclang/parse_functions.cpp +++ b/src/libclang/parse_functions.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "parse_functions.hpp" @@ -108,7 +107,8 @@ bool is_friend(const CXCursor& parent_cur) std::unique_ptr detail::parse_entity(const detail::parse_context& context, cpp_entity* parent, const CXCursor& cur, - const CXCursor& parent_cur) try + const CXCursor& parent_cur) +try { if (context.logger->is_verbose()) { diff --git a/src/libclang/parse_functions.hpp b/src/libclang/parse_functions.hpp index e0794c3..822b203 100644 --- a/src/libclang/parse_functions.hpp +++ b/src/libclang/parse_functions.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_PARSE_FUNCTIONS_HPP_INCLUDED #define CPPAST_PARSE_FUNCTIONS_HPP_INCLUDED diff --git a/src/libclang/preprocessor.cpp b/src/libclang/preprocessor.cpp index 0923e6a..bebfc34 100644 --- a/src/libclang/preprocessor.cpp +++ b/src/libclang/preprocessor.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "preprocessor.hpp" diff --git a/src/libclang/preprocessor.hpp b/src/libclang/preprocessor.hpp index a94cc35..826ccda 100644 --- a/src/libclang/preprocessor.hpp +++ b/src/libclang/preprocessor.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_PREPROCESSOR_HPP_INCLUDED #define CPPAST_PREPROCESSOR_HPP_INCLUDED diff --git a/src/libclang/raii_wrapper.hpp b/src/libclang/raii_wrapper.hpp index 2db0fae..604c634 100644 --- a/src/libclang/raii_wrapper.hpp +++ b/src/libclang/raii_wrapper.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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_RAII_WRAPPER_HPP_INCLUDED #define CPPAST_RAII_WRAPPER_HPP_INCLUDED diff --git a/src/libclang/template_parser.cpp b/src/libclang/template_parser.cpp index 04a319d..4f89952 100644 --- a/src/libclang/template_parser.cpp +++ b/src/libclang/template_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 #include diff --git a/src/libclang/type_parser.cpp b/src/libclang/type_parser.cpp index c32327d..a636b82 100644 --- a/src/libclang/type_parser.cpp +++ b/src/libclang/type_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "parse_functions.hpp" diff --git a/src/libclang/variable_parser.cpp b/src/libclang/variable_parser.cpp index cf96ceb..2bfb1db 100644 --- a/src/libclang/variable_parser.cpp +++ b/src/libclang/variable_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 "parse_functions.hpp" diff --git a/src/visitor.cpp b/src/visitor.cpp index fc03971..8cc66dd 100644 --- a/src/visitor.cpp +++ b/src/visitor.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a03f5cd..3b24dac 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ -# Copyright (C) 2017-2018 Jonathan Müller -# 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. diff --git a/test/code_generator.cpp b/test/code_generator.cpp index d51ca41..c86c9c2 100644 --- a/test/code_generator.cpp +++ b/test/code_generator.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_alias_template.cpp b/test/cpp_alias_template.cpp index 591356c..21b97af 100644 --- a/test/cpp_alias_template.cpp +++ b/test/cpp_alias_template.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_attribute.cpp b/test/cpp_attribute.cpp index d4f70da..0000626 100644 --- a/test/cpp_attribute.cpp +++ b/test/cpp_attribute.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -63,103 +62,97 @@ alignas(type) int var; REQUIRE(*args == '\0'); }; - auto count - = test_visit(*file, - [&](const cpp_entity& e) { - auto& attributes = e.attributes(); - REQUIRE(attributes.size() >= 1u); - auto& attr = attributes.front(); + auto count = test_visit( + *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(*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( + *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(*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( + *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); } diff --git a/test/cpp_class.cpp b/test/cpp_class.cpp index ec76e6b..59fa08e 100644 --- a/test/cpp_class.cpp +++ b/test/cpp_class.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -164,7 +163,7 @@ struct g REQUIRE(child.name() == "public"); REQUIRE(child.kind() == cpp_entity_kind::access_specifier_t); REQUIRE(static_cast(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(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(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(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); diff --git a/test/cpp_class_template.cpp b/test/cpp_class_template.cpp index bc119be..b25c0a3 100644 --- a/test/cpp_class_template.cpp +++ b/test/cpp_class_template.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_enum.cpp b/test/cpp_enum.cpp index 0d2c962..5bc233e 100644 --- a/test/cpp_enum.cpp +++ b/test/cpp_enum.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -81,9 +80,9 @@ enum ns::c : int {}; { REQUIRE(expr.kind() == cpp_expression_kind::unexposed_t); REQUIRE(static_cast(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(expr).expression().as_string() - == "a_a+2"); + static_cast(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))); } diff --git a/test/cpp_friend.cpp b/test/cpp_friend.cpp index 155c86c..e7e96b6 100644 --- a/test/cpp_friend.cpp +++ b/test/cpp_friend.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_function.cpp b/test/cpp_function.cpp index a906e17..2390d11 100644 --- a/test/cpp_function.cpp +++ b/test/cpp_function.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -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); } diff --git a/test/cpp_function_template.cpp b/test/cpp_function_template.cpp index 7a4023c..6f25958 100644 --- a/test/cpp_function_template.cpp +++ b/test/cpp_function_template.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_language_linkage.cpp b/test/cpp_language_linkage.cpp index 4f65ba5..1831d53 100644 --- a/test/cpp_language_linkage.cpp +++ b/test/cpp_language_linkage.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -57,23 +56,24 @@ enum f {}; REQUIRE(count == 3u); // check enums for their correct parent - count = test_visit(*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( + *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); } diff --git a/test/cpp_member_function.cpp b/test/cpp_member_function.cpp index 9d296fa..73a9ea1 100644 --- a/test/cpp_member_function.cpp +++ b/test/cpp_member_function.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -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::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); diff --git a/test/cpp_member_variable.cpp b/test/cpp_member_variable.cpp index b29a6ca..49ae9f1 100644 --- a/test/cpp_member_variable.cpp +++ b/test/cpp_member_variable.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_namespace.cpp b/test/cpp_namespace.cpp index da897af..4d4d7bb 100644 --- a/test/cpp_namespace.cpp +++ b/test/cpp_namespace.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_preprocessor.cpp b/test/cpp_preprocessor.cpp index 663dc6e..8e6180a 100644 --- a/test/cpp_preprocessor.cpp +++ b/test/cpp_preprocessor.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_static_assert.cpp b/test/cpp_static_assert.cpp index 1bae8f6..6d61194 100644 --- a/test/cpp_static_assert.cpp +++ b/test/cpp_static_assert.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_template_parameter.cpp b/test/cpp_template_parameter.cpp index d7afae0..c6484f2 100644 --- a/test/cpp_template_parameter.cpp +++ b/test/cpp_template_parameter.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -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( + *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(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"))); - } - else - REQUIRE(false); - } - }, - false); // can't check synopsis with comments + auto& param = static_cast(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"))); + } + 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( + *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(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(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( + *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(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(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(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); } diff --git a/test/cpp_token.cpp b/test/cpp_token.cpp index 2c04428..bfef257 100644 --- a/test/cpp_token.cpp +++ b/test/cpp_token.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_type_alias.cpp b/test/cpp_type_alias.cpp index bf669b3..98d46af 100644 --- a/test/cpp_type_alias.cpp +++ b/test/cpp_type_alias.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/cpp_variable.cpp b/test/cpp_variable.cpp index b60833d..610eb4b 100644 --- a/test/cpp_variable.cpp +++ b/test/cpp_variable.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -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); diff --git a/test/integration.cpp b/test/integration.cpp index caffcce..d39ed15 100644 --- a/test/integration.cpp +++ b/test/integration.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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" diff --git a/test/libclang_parser.cpp b/test/libclang_parser.cpp index 0c35c4a..4d3f3f6 100644 --- a/test/libclang_parser.cpp +++ b/test/libclang_parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/parser.cpp b/test/parser.cpp index 39e3e63..b5dd667 100644 --- a/test/parser.cpp +++ b/test/parser.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/test.cpp b/test/test.cpp index 7c1202b..4ac8169 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/test/test_parser.hpp b/test/test_parser.hpp index 661fdfb..839df1f 100644 --- a/test/test_parser.hpp +++ b/test/test_parser.hpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index 257c111..5dfa27a 100644 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt @@ -1,5 +1,5 @@ -# Copyright (C) 2017-2018 Jonathan Müller -# 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. add_executable(cppast_tool main.cpp) diff --git a/tool/main.cpp b/tool/main.cpp index 016acf0..f0f3a1e 100644 --- a/tool/main.cpp +++ b/tool/main.cpp @@ -1,6 +1,5 @@ -// Copyright (C) 2017-2019 Jonathan Müller -// 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 @@ -186,7 +185,8 @@ std::unique_ptr parse_file(const cppast::libclang_compile_conf return file; } -int main(int argc, char* argv[]) try +int main(int argc, char* argv[]) +try { cxxopts::Options option_list("cppast", "cppast - The commandline interface to the cppast library.\n");