Merge pull request #21 from bkryza/fix-cpp-type-kind-logging

Fix cpp type kind logging
This commit is contained in:
Bartek Kryza
2022-03-07 23:26:52 +01:00
committed by GitHub
7 changed files with 53 additions and 10 deletions

View File

@@ -18,7 +18,9 @@ set(UML_HEADERS_DIR ${PROJECT_SOURCE_DIR}/src/uml)
option(LLVM_CONFIG_PATH "Path to custom llvm-config executable")
if(LLVM_CONFIG_PATH)
message(STATUS "Using llvm-config from ${LLVM_CONFIG_PATH}")
set(LIBCLANG_LLVM_CONFIG_EXECUTABLE ${LLVM_CONFIG_PATH})
set(LLVM_CONFIG_BINARY ${LLVM_CONFIG_PATH})
endif(LLVM_CONFIG_PATH)
message(STATUS "Checking for fmt...")

View File

@@ -52,6 +52,10 @@ release/clang-uml --help
# To build using a specific installed version of LLVM use:
LLVM_CONFIG_PATH=/usr/bin/llvm-config-13 make release
# To build on macos, it is necessary to provide also path to LLVM cmake directory, e.g.:
export LLVM_PREFIX="/usr/local/Cellar/llvm@12/12.0.1_1"
LLVM_CONFIG_PATH="${LLVM_PREFIX}/bin/llvm-config" CMAKE_PREFIX_PATH="${LLVM_PREFIX}/lib/cmake/llvm/" make test
# Optionally
make install
# or

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

@@ -40,7 +40,7 @@ public:
package(const package &) = delete;
package(package &&) = default;
package &operator=(const package &) = delete;
package &operator=(package &&) = default;
package &operator=(package &&) = delete;
std::string full_name(bool relative) const override;

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_));