diff --git a/src/class_diagram/visitor/template_builder.cc b/src/class_diagram/visitor/template_builder.cc index 56150be0..ca4e3b23 100644 --- a/src/class_diagram/visitor/template_builder.cc +++ b/src/class_diagram/visitor/template_builder.cc @@ -582,13 +582,16 @@ clang::QualType template_builder::consume_context( template_parameter template_builder::process_type_argument( std::optional &parent, const clang::NamedDecl *cls, const clang::TemplateDecl *template_decl, - // const clang::TemplateArgument &arg, clang::QualType type, class_ &template_instantiation, size_t argument_index) { - auto type_name = common::to_string(type, &cls->getASTContext()); - std::optional argument; + if (type->getAs() != nullptr) { + type = type->getAs()->getNamedType(); + } + + auto type_name = common::to_string(type, &cls->getASTContext()); + LOG_DBG("Processing template {} type argument {}: {}, {}, {}", template_decl->getQualifiedNameAsString(), argument_index, type_name, type->getTypeClassName(), @@ -676,8 +679,6 @@ bool template_builder::find_relationships_in_unexposed_template_params( return found; } -// using token_it = std::vector::const_iterator; - namespace detail { std::string map_type_parameter_to_template_parameter( @@ -1107,6 +1108,7 @@ std::optional template_builder::try_as_record_type( type = consume_context(type, argument); auto type_name = common::to_string(type, template_decl->getASTContext()); + argument.set_type(type_name); const auto type_id = common::to_id(type_name); argument.set_id(type_id); @@ -1138,9 +1140,6 @@ std::optional template_builder::try_as_record_type( } else if (const auto *record_type_decl = record_type->getAsRecordDecl(); record_type_decl != nullptr) { -#if LLVM_VERSION_MAJOR >= 16 - argument.set_type(record_type_decl->getQualifiedNameAsString()); -#endif if (diagram().should_include(type_name)) { // Add dependency relationship to the parent // template diff --git a/src/class_diagram/visitor/template_builder.h b/src/class_diagram/visitor/template_builder.h index 1eaee5e8..8e783566 100644 --- a/src/class_diagram/visitor/template_builder.h +++ b/src/class_diagram/visitor/template_builder.h @@ -102,10 +102,8 @@ public: template_parameter process_type_argument( std::optional &parent, const clang::NamedDecl *cls, - const clang::TemplateDecl *base_template_decl, - // const clang::TemplateArgument &arg, - clang::QualType type, model::class_ &template_instantiation, - size_t argument_index); + const clang::TemplateDecl *base_template_decl, clang::QualType type, + model::class_ &template_instantiation, size_t argument_index); common::model::template_parameter process_template_argument( const clang::TemplateArgument &arg); diff --git a/src/class_diagram/visitor/translation_unit_visitor.cc b/src/class_diagram/visitor/translation_unit_visitor.cc index 7f957783..24d77996 100644 --- a/src/class_diagram/visitor/translation_unit_visitor.cc +++ b/src/class_diagram/visitor/translation_unit_visitor.cc @@ -1839,7 +1839,6 @@ void translation_unit_visitor::process_field( // Process the type which is template instantiation of some sort if (template_field_type != nullptr && !field_type_is_template_template_parameter) { - // Build the template instantiation for the field type auto template_specialization_ptr = tbuilder().build(&field_declaration, *template_field_type, {&c}); diff --git a/src/common/clang_utils.cc b/src/common/clang_utils.cc index 89b5869e..7c640a2f 100644 --- a/src/common/clang_utils.cc +++ b/src/common/clang_utils.cc @@ -116,8 +116,8 @@ std::string to_string(const clang::QualType &type, const clang::ASTContext &ctx, bool try_canonical) { clang::PrintingPolicy print_policy(ctx.getLangOpts()); - print_policy.SuppressScope = false; - print_policy.PrintCanonicalTypes = false; + print_policy.SuppressScope = 0; + print_policy.PrintCanonicalTypes = 0; std::string result; diff --git a/tests/t00014/test_case.h b/tests/t00014/test_case.h index d1868352..78bcd34b 100644 --- a/tests/t00014/test_case.h +++ b/tests/t00014/test_case.h @@ -154,7 +154,6 @@ TEST_CASE("t00014", "[test-case][class]") REQUIRE(json::IsClass(j, "A")); REQUIRE(json::IsClass(j, "A")); REQUIRE(json::IsClass(j, "B")); - save_json(config.output_directory() + "/" + diagram->name + ".json", j); } }