Skip to content

Commit 5bdfa24

Browse files
committed
Fixed issues with sequence diagram caller context (#415)
1 parent f312e46 commit 5bdfa24

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

src/sequence_diagram/model/diagram.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,12 @@ void diagram::add_participant(std::unique_ptr<participant> p)
110110
else {
111111
if (participants_.at(participant_id)->full_name(false) !=
112112
p->full_name(false)) {
113-
LOG_ERROR("Participant with id {} already exists but has different "
114-
"name {} [{}], {} [{}]",
113+
LOG_WARN("Participant with id {} already exists but has different "
114+
"name {} [{}], {} [{}]",
115115
participant_id.value(),
116116
participants_.at(participant_id)->full_name(false),
117117
participants_.at(participant_id)->id().usr(),
118118
p->full_name(false), p->id().usr());
119-
120-
assert(participants_.at(participant_id)->full_name(false) ==
121-
p->full_name(false));
122119
}
123120
}
124121
}

src/sequence_diagram/visitor/call_expression_context.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ call_expression_context::call_expression_context() = default;
2525
void call_expression_context::reset()
2626
{
2727
current_caller_id_ = eid_t{};
28+
reset_declarations();
29+
}
30+
31+
void call_expression_context::reset_declarations()
32+
{
2833
current_class_decl_ = nullptr;
2934
current_class_template_decl_ = nullptr;
3035
current_class_template_specialization_decl_ = nullptr;
@@ -105,27 +110,32 @@ clang::ASTContext *call_expression_context::get_ast_context() const
105110

106111
void call_expression_context::update(clang::CXXRecordDecl *cls)
107112
{
113+
reset_declarations();
108114
current_class_decl_ = cls;
109115
}
110116

111117
void call_expression_context::update(clang::ObjCInterfaceDecl *cls)
112118
{
119+
reset_declarations();
113120
objc_interface_decl_ = cls;
114121
}
115122

116123
void call_expression_context::update(clang::ObjCProtocolDecl *cls)
117124
{
125+
reset_declarations();
118126
objc_protocol_decl_ = cls;
119127
}
120128

121129
void call_expression_context::update(
122130
clang::ClassTemplateSpecializationDecl *clst)
123131
{
132+
reset_declarations();
124133
current_class_template_specialization_decl_ = clst;
125134
}
126135

127136
void call_expression_context::update(clang::ClassTemplateDecl *clst)
128137
{
138+
reset_declarations();
129139
current_class_template_decl_ = clst;
130140
}
131141

@@ -136,6 +146,7 @@ void call_expression_context::update(clang::CXXMethodDecl *method)
136146

137147
void call_expression_context::update(clang::ObjCMethodDecl *method)
138148
{
149+
reset_declarations();
139150
current_objc_method_decl_ = method;
140151
}
141152

src/sequence_diagram/visitor/call_expression_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct call_expression_context {
5656
* @brief Reset call expression context to the original state.
5757
*/
5858
void reset();
59+
void reset_declarations();
5960

6061
/**
6162
* @brief Verify that the context is in a valid state.

src/sequence_diagram/visitor/translation_unit_visitor.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,17 @@ void translation_unit_visitor::process_function_parameters(
31013101
for (const auto *param : declaration.parameters()) {
31023102
auto parameter_type =
31033103
common::to_string(param->getType(), param->getASTContext());
3104+
3105+
if (param->getType().isConstQualified() &&
3106+
!param->getType()->isPointerType() &&
3107+
!param->getType()->isReferenceType()) {
3108+
auto non_const_type = param->getType();
3109+
non_const_type.removeLocalConst();
3110+
3111+
parameter_type =
3112+
common::to_string(non_const_type, param->getASTContext());
3113+
}
3114+
31043115
common::ensure_lambda_type_is_relative(config(), parameter_type);
31053116
parameter_type = simplify_system_template(parameter_type);
31063117

uml/sequence/template_builder_sequence.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ exclude:
1818
using_namespace:
1919
- clanguml
2020
from:
21-
- function: "clanguml::common::visitor::template_builder<VisitorT>::build(const clang::NamedDecl &,common::model::template_element &,const clang::NamedDecl *,const clang::TemplateDecl *,const clang::ArrayRef<clang::TemplateArgument>,std::string,std::optional<common::model::template_element *>)"
21+
- function: "clanguml::common::visitor::template_builder<VisitorT>::build(const clang::NamedDecl &,common::model::template_element &,const clang::NamedDecl *,const clang::TemplateDecl *,clang::ArrayRef<clang::TemplateArgument>,std::string,std::optional<common::model::template_element *>)"

0 commit comments

Comments
 (0)