From 6894a025cafa0c7d74353b09c7fa04f237b0bd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Thu, 13 Apr 2017 11:35:22 +0200 Subject: [PATCH] Remove full_name() function Doesn't work for templates. --- include/cppast/cpp_entity.hpp | 5 ----- src/cpp_entity.cpp | 18 ------------------ test/test_parser.hpp | 20 +++++++++++++++++++- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/include/cppast/cpp_entity.hpp b/include/cppast/cpp_entity.hpp index f955609..181f9f7 100644 --- a/include/cppast/cpp_entity.hpp +++ b/include/cppast/cpp_entity.hpp @@ -162,11 +162,6 @@ namespace cppast /// \returns Whether or not the given entity is "friended", /// that is, its declaration exists as part of a [cppast::cpp_friend]() declaration. bool is_friended(const cpp_entity& e) noexcept; - - /// \returns The full name of the [cppast::cpp_entity](), with all scopes. - /// \notes Enitites without a name ([cppast::cpp_using_declaration]() etc.) do not have a full name either. - /// \notes For (template) parameters the full name is the name itself. - std::string full_name(const cpp_entity& e); } // namespace cppast #endif // CPPAST_CPP_ENTITY_HPP_INCLUDED diff --git a/src/cpp_entity.cpp b/src/cpp_entity.cpp index 47ea237..bb00a11 100644 --- a/src/cpp_entity.cpp +++ b/src/cpp_entity.cpp @@ -42,21 +42,3 @@ bool cppast::is_templated(const cpp_entity& e) noexcept return false; return e.parent().value().name() == e.name(); } - -std::string cppast::full_name(const cpp_entity& e) -{ - if (e.name().empty()) - return ""; - else if (is_parameter(e.kind())) - // parameters don't have a full name - return e.name(); - - std::string scopes; - - for (auto cur = e.parent(); cur; cur = cur.value().parent()) - // prepend each scope, if there is any - type_safe::with(cur.value().scope_name(), - [&](const std::string& cur_scope) { scopes = cur_scope + "::" + scopes; }); - - return scopes + e.name(); -} diff --git a/test/test_parser.hpp b/test/test_parser.hpp index eeb09ef..0b95ff2 100644 --- a/test/test_parser.hpp +++ b/test/test_parser.hpp @@ -140,13 +140,31 @@ unsigned count_children(const Entity& cont) return std::distance(cont.begin(), cont.end()); } +inline std::string full_name(const cppast::cpp_entity& e) +{ + if (e.name().empty()) + return ""; + else if (cppast::is_parameter(e.kind())) + // parameters don't have a full name + return e.name(); + + std::string scopes; + + for (auto cur = e.parent(); cur; cur = cur.value().parent()) + // prepend each scope, if there is any + type_safe::with(cur.value().scope_name(), + [&](const std::string& cur_scope) { scopes = cur_scope + "::" + scopes; }); + + return scopes + e.name(); +} + // checks the full name/parent inline void check_parent(const cppast::cpp_entity& e, const char* parent_name, const char* full_name) { REQUIRE(e.parent()); REQUIRE(e.parent().value().name() == parent_name); - REQUIRE(cppast::full_name(e) == full_name); + REQUIRE(::full_name(e) == full_name); } bool equal_types(const cppast::cpp_entity_index& idx, const cppast::cpp_type& parsed,