From 2033ca29c00f43c665cc1a7d592d24a6b6fad326 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sat, 13 Mar 2021 20:47:22 +0100 Subject: [PATCH] Refactored is variadic to a method of cursor --- src/cx/cursor.h | 6 ++++++ src/uml/class_diagram_visitor.h | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cx/cursor.h b/src/cx/cursor.h index 8a6ddbc8..6e3a45c2 100644 --- a/src/cx/cursor.h +++ b/src/cx/cursor.h @@ -239,6 +239,12 @@ public: return clang_Cursor_getTranslationUnit(m_cursor); } + bool is_template_parameter_variadic() const + { + const auto &tokens = tokenize(); + return tokens.size() > 2 && tokens[1] == "..."; + } + std::string usr() const { return to_string(clang_getCursorUSR(m_cursor)); } CXSourceRange extent() const { return clang_getCursorExtent(m_cursor); } diff --git a/src/uml/class_diagram_visitor.h b/src/uml/class_diagram_visitor.h index bfee1e9d..69431c41 100644 --- a/src/uml/class_diagram_visitor.h +++ b/src/uml/class_diagram_visitor.h @@ -330,13 +330,13 @@ static enum CXChildVisitResult class_visitor( ret = CXChildVisit_Continue; break; case CXCursor_TemplateTypeParameter: { - const auto &tokens = cursor.tokenize(); - spdlog::info("Found template type parameter: {}: {}, [{}]", cursor, - cursor.type(), fmt::join(tokens, ", ")); + spdlog::info("Found template type parameter: {}: {}, isvariadic={}", + cursor, cursor.type(), cursor.is_template_parameter_variadic()); + class_template ct; ct.type = ""; ct.default_value = ""; - ct.is_variadic = tokens.size() > 2 && tokens[1] == "..."; + ct.is_variadic = cursor.is_template_parameter_variadic(); ct.name = cursor.spelling(); if (ct.is_variadic) ct.name += "..."; @@ -347,6 +347,7 @@ static enum CXChildVisitResult class_visitor( case CXCursor_NonTypeTemplateParameter: { spdlog::info("Found template nontype parameter: {}: {}", cursor.spelling(), cursor.type()); + class_template ct; ct.type = cursor.type().canonical().spelling(); ct.name = cursor.spelling();