From 8684bc861bb0b308c0f6ce049f26f8665b7ba333 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sun, 4 Dec 2022 12:10:52 +0100 Subject: [PATCH] Fixed lambda sequence diagram test case --- .../visitor/translation_unit_visitor.cc | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/sequence_diagram/visitor/translation_unit_visitor.cc b/src/sequence_diagram/visitor/translation_unit_visitor.cc index 409b84fd..324b5d79 100644 --- a/src/sequence_diagram/visitor/translation_unit_visitor.cc +++ b/src/sequence_diagram/visitor/translation_unit_visitor.cc @@ -1327,35 +1327,6 @@ void translation_unit_visitor::process_template_specialization_argument( simplify_system_template(argument, argument.to_string(config().using_namespace(), false)); } - else if (arg.getAsType()->getAsCXXRecordDecl()) { - if (arg.getAsType()->getAsCXXRecordDecl()->isLambda()) { - if (get_unique_id( - arg.getAsType()->getAsCXXRecordDecl()->getID()) - .has_value()) { - argument.set_name(get_participant( - get_unique_id( - arg.getAsType()->getAsCXXRecordDecl()->getID()) - .value()) - .value() - .full_name(false)); - } - else { - auto parent_full_name = - get_participant(context().caller_id()) - .value() - .full_name_no_ns(); - - const auto location = - arg.getAsType()->getAsCXXRecordDecl()->getLocation(); - const auto type_name = - fmt::format("{}##(lambda {}:{})", parent_full_name, - source_manager().getSpellingLineNumber(location), - source_manager().getSpellingColumnNumber(location)); - - argument.set_name(type_name); - } - } - } else if (arg.getAsType()->getAs()) { auto type_name = common::to_string(arg.getAsType(), cls->getASTContext()); @@ -1387,6 +1358,32 @@ void translation_unit_visitor::process_template_specialization_argument( argument.set_name(type_name); } + else if (arg.getAsType()->getAsCXXRecordDecl() && + arg.getAsType()->getAsCXXRecordDecl()->isLambda()) { + if (get_unique_id(arg.getAsType()->getAsCXXRecordDecl()->getID()) + .has_value()) { + argument.set_name(get_participant( + get_unique_id( + arg.getAsType()->getAsCXXRecordDecl()->getID()) + .value()) + .value() + .full_name(false)); + } + else { + auto parent_full_name = get_participant(context().caller_id()) + .value() + .full_name_no_ns(); + + const auto location = + arg.getAsType()->getAsCXXRecordDecl()->getLocation(); + const auto type_name = + fmt::format("{}##(lambda {}:{})", parent_full_name, + source_manager().getSpellingLineNumber(location), + source_manager().getSpellingColumnNumber(location)); + + argument.set_name(type_name); + } + } else { auto type_name = common::to_string(arg.getAsType(), cls->getASTContext());