Added to_string function for cpp_entity_kind for logging

This commit is contained in:
Bartek Kryza
2022-03-07 22:32:46 +01:00
parent bbd6133b20
commit b4d691539c
4 changed files with 46 additions and 9 deletions

View File

@@ -728,10 +728,8 @@ void translation_unit_visitor::process_field(
auto tr_declaration = cppast::to_string(tr);
#ifndef __APPLE__
LOG_DBG("Processing field {} with unreferenced type of kind {}", mv.name(),
tr.kind());
#endif
cx::to_string(tr.kind()));
if (tr.kind() == cppast::cpp_type_kind::builtin_t) {
LOG_DBG("Builtin type found for field: {}", m.name());
@@ -1214,10 +1212,8 @@ bool translation_unit_visitor::find_relationships(const cppast::cpp_type &t_,
const auto fn =
cx::util::full_name(cppast::remove_cv(t_), ctx.entity_index(), false);
#ifndef __APPLE__
LOG_DBG("Finding relationships for type {}, {}, {}", cppast::to_string(t_),
t_.kind(), fn);
#endif
cx::to_string(t_.kind()), fn);
relationship_t relationship_type = relationship_hint;
const auto &t = cppast::remove_cv(cx::util::unreferenced(t_));

View File

@@ -38,6 +38,47 @@ std::string to_string(CXString &&cxs)
return r;
}
std::string to_string(cppast::cpp_type_kind t)
{
using namespace cppast;
switch (t) {
case cpp_type_kind::builtin_t:
return "builtin";
case cpp_type_kind::user_defined_t:
return "user_defined";
case cpp_type_kind::auto_t:
return "auto";
case cpp_type_kind::decltype_t:
return "decltype";
case cpp_type_kind::decltype_auto_t:
return "decltype_auto";
case cpp_type_kind::cv_qualified_t:
return "cv_qualified";
case cpp_type_kind::pointer_t:
return "pointer";
case cpp_type_kind::reference_t:
return "reference";
case cpp_type_kind::array_t:
return "array";
case cpp_type_kind::function_t:
return "function";
case cpp_type_kind::member_function_t:
return "member_function";
case cpp_type_kind::member_object_t:
return "member_object";
case cpp_type_kind::template_parameter_t:
return "template_parameter";
case cpp_type_kind::template_instantiation_t:
return "template_instantiation";
case cpp_type_kind::dependent_t:
return "dependent";
case cpp_type_kind::unexposed_t:
return "unexposed";
default:
return "invalid";
}
}
std::string full_name(
const common::model::namespace_ &current_ns, const cppast::cpp_entity &e)
{

View File

@@ -42,6 +42,8 @@ namespace util {
*/
std::string to_string(CXString &&cxs);
std::string to_string(cppast::cpp_type_kind t);
std::string full_name(
const common::model::namespace_ &current_ns, const cppast::cpp_entity &e);

View File

@@ -379,10 +379,8 @@ bool translation_unit_visitor::find_relationships(const cppast::cpp_type &t_,
const auto fn_ns = cx::util::ns(cppast::remove_cv(t_), ctx.entity_index());
#ifndef __APPLE__
LOG_DBG("Finding relationships for type {}, {}, {}", cppast::to_string(t_),
t_.kind(), fn);
#endif
cx::to_string(t_.kind()), fn);
relationship_t relationship_type = relationship_hint;
const auto &t = cppast::remove_cv(cx::util::unreferenced(t_));