Refactored sequence diagram visitor
This commit is contained in:
@@ -2008,5 +2008,4 @@ translation_unit_visitor::get_ast_local_id(int64_t local_id)
|
|||||||
|
|
||||||
return local_ast_id_map_.at(local_id);
|
return local_ast_id_map_.at(local_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,21 +78,23 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
|||||||
using clanguml::sequence_diagram::model::activity;
|
using clanguml::sequence_diagram::model::activity;
|
||||||
using clanguml::sequence_diagram::model::message;
|
using clanguml::sequence_diagram::model::message;
|
||||||
|
|
||||||
|
// Skip casts, moves and such
|
||||||
if (expr->isCallToStdMove())
|
if (expr->isCallToStdMove())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (expr->isImplicitCXXThis())
|
if (expr->isImplicitCXXThis())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (/*clang::dyn_cast_or_null<clang::CXXOperatorCallExpr>(expr) ||*/
|
if (clang::dyn_cast_or_null<clang::ImplicitCastExpr>(expr))
|
||||||
clang::dyn_cast_or_null<clang::ImplicitCastExpr>(expr))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Skip if current class was excluded in the config
|
||||||
if (current_class_decl_ &&
|
if (current_class_decl_ &&
|
||||||
!diagram().should_include(
|
!diagram().should_include(
|
||||||
current_class_decl_->getQualifiedNameAsString()))
|
current_class_decl_->getQualifiedNameAsString()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Skip if current function was excluded in the config
|
||||||
if (current_function_decl_ &&
|
if (current_function_decl_ &&
|
||||||
!diagram().should_include(
|
!diagram().should_include(
|
||||||
current_function_decl_->getQualifiedNameAsString()))
|
current_function_decl_->getQualifiedNameAsString()))
|
||||||
@@ -102,11 +104,13 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
|||||||
m.type = message_t::kCall;
|
m.type = message_t::kCall;
|
||||||
|
|
||||||
if (current_class_decl_ != nullptr) {
|
if (current_class_decl_ != nullptr) {
|
||||||
|
// Handle call expression within some class method
|
||||||
assert(current_method_decl_ != nullptr);
|
assert(current_method_decl_ != nullptr);
|
||||||
m.from = current_class_decl_->getQualifiedNameAsString();
|
m.from = current_class_decl_->getQualifiedNameAsString();
|
||||||
m.from_usr = current_method_decl_->getID();
|
m.from_usr = current_method_decl_->getID();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Handle call expression within free function
|
||||||
m.from = current_function_decl_->getQualifiedNameAsString() + "()";
|
m.from = current_function_decl_->getQualifiedNameAsString() + "()";
|
||||||
m.from_usr = current_function_decl_->getID();
|
m.from_usr = current_function_decl_->getID();
|
||||||
}
|
}
|
||||||
@@ -118,45 +122,45 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
|||||||
if (const auto *operator_call_expr =
|
if (const auto *operator_call_expr =
|
||||||
clang::dyn_cast_or_null<clang::CXXOperatorCallExpr>(expr);
|
clang::dyn_cast_or_null<clang::CXXOperatorCallExpr>(expr);
|
||||||
operator_call_expr != nullptr) {
|
operator_call_expr != nullptr) {
|
||||||
[[maybe_unused]] const auto *callee_method_decl =
|
// TODO: Handle C++ operator calls
|
||||||
operator_call_expr->getCalleeDecl();
|
|
||||||
}
|
}
|
||||||
else if (const auto *method_call_expr =
|
else if (const auto *method_call_expr =
|
||||||
clang::dyn_cast_or_null<clang::CXXMemberCallExpr>(expr);
|
clang::dyn_cast_or_null<clang::CXXMemberCallExpr>(expr);
|
||||||
method_call_expr != nullptr) {
|
method_call_expr != nullptr) {
|
||||||
const auto *callee_decl = method_call_expr->getMethodDecl()
|
|
||||||
? method_call_expr->getMethodDecl()->getParent()
|
|
||||||
: nullptr;
|
|
||||||
|
|
||||||
if (!callee_decl ||
|
// Get callee declaration as methods parent
|
||||||
!diagram().should_include(
|
const auto *method_decl = method_call_expr->getMethodDecl();
|
||||||
/*namespace_{*/ callee_decl->getQualifiedNameAsString()))
|
const auto *callee_decl =
|
||||||
|
method_decl ? method_decl->getParent() : nullptr;
|
||||||
|
|
||||||
|
if (!(callee_decl &&
|
||||||
|
diagram().should_include(
|
||||||
|
callee_decl->getQualifiedNameAsString())))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
m.to = method_call_expr->getMethodDecl()
|
m.to = callee_decl->getQualifiedNameAsString();
|
||||||
->getParent()
|
m.to_usr = method_decl->getID();
|
||||||
->getQualifiedNameAsString();
|
m.message = method_decl->getNameAsString();
|
||||||
m.to_usr = method_call_expr->getMethodDecl()->getID();
|
|
||||||
|
|
||||||
m.message = method_call_expr->getMethodDecl()->getNameAsString();
|
|
||||||
|
|
||||||
m.return_type = method_call_expr->getCallReturnType(current_ast_context)
|
m.return_type = method_call_expr->getCallReturnType(current_ast_context)
|
||||||
.getAsString();
|
.getAsString();
|
||||||
}
|
}
|
||||||
else if (const auto *function_call_expr =
|
else if (const auto *function_call_expr =
|
||||||
clang::dyn_cast_or_null<clang::CallExpr>(expr);
|
clang::dyn_cast_or_null<clang::CallExpr>(expr);
|
||||||
function_call_expr != nullptr) {
|
function_call_expr != nullptr) {
|
||||||
assert(function_call_expr->getCalleeDecl()->getAsFunction());
|
|
||||||
|
|
||||||
m.to = function_call_expr->getCalleeDecl()
|
const auto *callee_decl = function_call_expr->getCalleeDecl();
|
||||||
->getAsFunction()
|
|
||||||
->getQualifiedNameAsString() +
|
if (!callee_decl)
|
||||||
"()";
|
return true;
|
||||||
m.message = function_call_expr->getCalleeDecl()
|
|
||||||
->getAsFunction()
|
const auto *callee_function = callee_decl->getAsFunction();
|
||||||
->getNameAsString();
|
|
||||||
m.to_usr =
|
if (!callee_function)
|
||||||
function_call_expr->getCalleeDecl()->getAsFunction()->getID();
|
return true;
|
||||||
|
|
||||||
|
m.to = callee_function->getQualifiedNameAsString() + "()";
|
||||||
|
m.message = callee_function->getNameAsString();
|
||||||
|
m.to_usr = callee_function->getID();
|
||||||
m.return_type =
|
m.return_type =
|
||||||
function_call_expr->getCallReturnType(current_ast_context)
|
function_call_expr->getCallReturnType(current_ast_context)
|
||||||
.getAsString();
|
.getAsString();
|
||||||
|
|||||||
Reference in New Issue
Block a user