Fixed handling properties of template methods (e.g. is_constructor)
This commit is contained in:
@@ -1282,23 +1282,7 @@ void translation_unit_visitor::process_method(
|
|||||||
class_method method{common::access_specifier_to_access_t(mf.getAccess()),
|
class_method method{common::access_specifier_to_access_t(mf.getAccess()),
|
||||||
util::trim(method_name), method_return_type};
|
util::trim(method_name), method_return_type};
|
||||||
|
|
||||||
const bool is_constructor = c.name() == method_name;
|
process_method_properties(mf, c, method_name, method);
|
||||||
const bool is_destructor = fmt::format("~{}", c.name()) == method_name;
|
|
||||||
|
|
||||||
method.is_pure_virtual(mf.isPure());
|
|
||||||
method.is_virtual(mf.isVirtual());
|
|
||||||
method.is_const(mf.isConst());
|
|
||||||
method.is_defaulted(mf.isDefaulted());
|
|
||||||
method.is_deleted(mf.isDeleted());
|
|
||||||
method.is_static(mf.isStatic());
|
|
||||||
method.is_operator(mf.isOverloadedOperator());
|
|
||||||
method.is_constexpr(mf.isConstexprSpecified() && !is_constructor);
|
|
||||||
method.is_consteval(mf.isConsteval());
|
|
||||||
method.is_constructor(is_constructor);
|
|
||||||
method.is_destructor(is_destructor);
|
|
||||||
method.is_move_assignment(mf.isMoveAssignmentOperator());
|
|
||||||
method.is_copy_assignment(mf.isCopyAssignmentOperator());
|
|
||||||
method.is_noexcept(isNoexceptExceptionSpec(mf.getExceptionSpecType()));
|
|
||||||
|
|
||||||
process_comment(mf, method);
|
process_comment(mf, method);
|
||||||
|
|
||||||
@@ -1374,6 +1358,28 @@ void translation_unit_visitor::process_method(
|
|||||||
|
|
||||||
c.add_method(std::move(method));
|
c.add_method(std::move(method));
|
||||||
}
|
}
|
||||||
|
void translation_unit_visitor::process_method_properties(
|
||||||
|
const clang::CXXMethodDecl &mf, const class_ &c,
|
||||||
|
const std::string &method_name, class_method &method) const
|
||||||
|
{
|
||||||
|
const bool is_constructor = c.name() == method_name;
|
||||||
|
const bool is_destructor = fmt::format("~{}", c.name()) == method_name;
|
||||||
|
|
||||||
|
method.is_pure_virtual(mf.isPure());
|
||||||
|
method.is_virtual(mf.isVirtual());
|
||||||
|
method.is_const(mf.isConst());
|
||||||
|
method.is_defaulted(mf.isDefaulted());
|
||||||
|
method.is_deleted(mf.isDeleted());
|
||||||
|
method.is_static(mf.isStatic());
|
||||||
|
method.is_operator(mf.isOverloadedOperator());
|
||||||
|
method.is_constexpr(mf.isConstexprSpecified() && !is_constructor);
|
||||||
|
method.is_consteval(mf.isConsteval());
|
||||||
|
method.is_constructor(is_constructor);
|
||||||
|
method.is_destructor(is_destructor);
|
||||||
|
method.is_move_assignment(mf.isMoveAssignmentOperator());
|
||||||
|
method.is_copy_assignment(mf.isCopyAssignmentOperator());
|
||||||
|
method.is_noexcept(isNoexceptExceptionSpec(mf.getExceptionSpecType()));
|
||||||
|
}
|
||||||
|
|
||||||
void translation_unit_visitor::
|
void translation_unit_visitor::
|
||||||
process_function_parameter_find_relationships_in_autotype(
|
process_function_parameter_find_relationships_in_autotype(
|
||||||
@@ -1439,11 +1445,19 @@ void translation_unit_visitor::process_template_method(
|
|||||||
util::trim(mf.getNameAsString()),
|
util::trim(mf.getNameAsString()),
|
||||||
mf.getTemplatedDecl()->getReturnType().getAsString()};
|
mf.getTemplatedDecl()->getReturnType().getAsString()};
|
||||||
|
|
||||||
method.is_pure_virtual(mf.getTemplatedDecl()->isPure());
|
auto method_name = mf.getNameAsString();
|
||||||
method.is_virtual(false);
|
if (mf.isTemplated()) {
|
||||||
method.is_const(false);
|
// Sometimes in template specializations method names contain the
|
||||||
method.is_defaulted(mf.getTemplatedDecl()->isDefaulted());
|
// template parameters for some reason - drop them
|
||||||
method.is_static(mf.getTemplatedDecl()->isStatic());
|
// Is there a better way to do this?
|
||||||
|
method_name = method_name.substr(0, method_name.find('<'));
|
||||||
|
}
|
||||||
|
|
||||||
|
util::if_not_null(
|
||||||
|
clang::dyn_cast<clang::CXXMethodDecl>(mf.getTemplatedDecl()),
|
||||||
|
[&](const auto *decl) {
|
||||||
|
process_method_properties(*decl, c, method_name, method);
|
||||||
|
});
|
||||||
|
|
||||||
process_template_parameters(mf, method);
|
process_template_parameters(mf, method);
|
||||||
|
|
||||||
|
|||||||
@@ -251,5 +251,8 @@ private:
|
|||||||
// If yes, then we need to skip it
|
// If yes, then we need to skip it
|
||||||
// TODO: There must be a better way to do this...
|
// TODO: There must be a better way to do this...
|
||||||
std::set<std::string> processed_template_qualified_names_;
|
std::set<std::string> processed_template_qualified_names_;
|
||||||
|
void process_method_properties(const clang::CXXMethodDecl &mf,
|
||||||
|
const class_ &c, const std::string &method_name,
|
||||||
|
class_method &method) const;
|
||||||
};
|
};
|
||||||
} // namespace clanguml::class_diagram::visitor
|
} // namespace clanguml::class_diagram::visitor
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ public:
|
|||||||
: private_member{i}
|
: private_member{i}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
A(T t)
|
||||||
|
: private_member{t.get()}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
A(A &&) = default;
|
A(A &&) = default;
|
||||||
A(const A &) = delete;
|
A(const A &) = delete;
|
||||||
virtual ~A() = default;
|
virtual ~A() = default;
|
||||||
|
|||||||
Reference in New Issue
Block a user