Fixed clang-tidy warnings
This commit is contained in:
@@ -298,8 +298,6 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
|||||||
|
|
||||||
void generator::generate(const concept_ &c, std::ostream &ostr) const
|
void generator::generate(const concept_ &c, std::ostream &ostr) const
|
||||||
{
|
{
|
||||||
namespace plantuml_common = clanguml::common::generators::plantuml;
|
|
||||||
|
|
||||||
std::string class_type{"class"};
|
std::string class_type{"class"};
|
||||||
|
|
||||||
ostr << class_type << " " << c.alias() << " <<concept>>";
|
ostr << class_type << " " << c.alias() << " <<concept>>";
|
||||||
@@ -313,9 +311,8 @@ void generator::generate(const concept_ &c, std::ostream &ostr) const
|
|||||||
|
|
||||||
ostr << " {" << '\n';
|
ostr << " {" << '\n';
|
||||||
|
|
||||||
if (true &&
|
// TODO: add option to enable/disable this
|
||||||
(c.requires_parameters().size() + c.requires_statements().size()) >
|
if (c.requires_parameters().size() + c.requires_statements().size() > 0) {
|
||||||
0) { // TODO: add option to enable/disable this
|
|
||||||
std::vector<std::string> parameters;
|
std::vector<std::string> parameters;
|
||||||
parameters.reserve(c.requires_parameters().size());
|
parameters.reserve(c.requires_parameters().size());
|
||||||
for (const auto &p : c.requires_parameters()) {
|
for (const auto &p : c.requires_parameters()) {
|
||||||
|
|||||||
@@ -90,4 +90,4 @@ const std::vector<std::string> &concept_::requires_statements() const
|
|||||||
return requires_statements_;
|
return requires_statements_;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace clanguml::class_diagram::model
|
||||||
|
|||||||
@@ -68,4 +68,4 @@ private:
|
|||||||
|
|
||||||
std::vector<std::string> requires_statements_;
|
std::vector<std::string> requires_statements_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace clanguml::class_diagram::model
|
||||||
@@ -294,7 +294,8 @@ bool translation_unit_visitor::VisitClassTemplateDecl(
|
|||||||
|
|
||||||
set_ast_local_id(cls->getID(), id);
|
set_ast_local_id(cls->getID(), id);
|
||||||
|
|
||||||
llvm::SmallVector<const clang::Expr *, 24> constraints{};
|
constexpr auto kMaxConstraintCount = 24U;
|
||||||
|
llvm::SmallVector<const clang::Expr *, kMaxConstraintCount> constraints{};
|
||||||
if (cls->hasAssociatedConstraints()) {
|
if (cls->hasAssociatedConstraints()) {
|
||||||
cls->getAssociatedConstraints(constraints);
|
cls->getAssociatedConstraints(constraints);
|
||||||
}
|
}
|
||||||
@@ -326,7 +327,7 @@ bool translation_unit_visitor::VisitRecordDecl(clang::RecordDecl *rec)
|
|||||||
if (source_manager().isInSystemHeader(rec->getSourceRange().getBegin()))
|
if (source_manager().isInSystemHeader(rec->getSourceRange().getBegin()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (clang::dyn_cast_or_null<clang::CXXRecordDecl>(rec))
|
if (clang::dyn_cast_or_null<clang::CXXRecordDecl>(rec) != nullptr)
|
||||||
// This is handled by VisitCXXRecordDecl()
|
// This is handled by VisitCXXRecordDecl()
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -401,7 +402,8 @@ bool translation_unit_visitor::TraverseConceptDecl(clang::ConceptDecl *cpt)
|
|||||||
|
|
||||||
process_template_parameters(*cpt, *concept_model);
|
process_template_parameters(*cpt, *concept_model);
|
||||||
|
|
||||||
llvm::SmallVector<const clang::Expr *, 24> constraints{};
|
constexpr auto kMaxConstraintCount = 24U;
|
||||||
|
llvm::SmallVector<const clang::Expr *, kMaxConstraintCount> constraints{};
|
||||||
if (cpt->hasAssociatedConstraints()) {
|
if (cpt->hasAssociatedConstraints()) {
|
||||||
cpt->getAssociatedConstraints(constraints);
|
cpt->getAssociatedConstraints(constraints);
|
||||||
}
|
}
|
||||||
@@ -410,7 +412,7 @@ bool translation_unit_visitor::TraverseConceptDecl(clang::ConceptDecl *cpt)
|
|||||||
find_relationships_in_constraint_expression(*concept_model, expr);
|
find_relationships_in_constraint_expression(*concept_model, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpt->getConstraintExpr()) {
|
if (cpt->getConstraintExpr() != nullptr) {
|
||||||
process_constraint_requirements(
|
process_constraint_requirements(
|
||||||
cpt, cpt->getConstraintExpr(), *concept_model);
|
cpt, cpt->getConstraintExpr(), *concept_model);
|
||||||
|
|
||||||
@@ -476,54 +478,76 @@ void translation_unit_visitor::process_constraint_requirements(
|
|||||||
const auto *simple_req =
|
const auto *simple_req =
|
||||||
llvm::dyn_cast<clang::concepts::ExprRequirement>(req);
|
llvm::dyn_cast<clang::concepts::ExprRequirement>(req);
|
||||||
|
|
||||||
auto simple_expr = common::to_string(simple_req->getExpr());
|
if (simple_req != nullptr) {
|
||||||
|
util::apply_if_not_null(
|
||||||
|
simple_req->getExpr(), [&concept_model](const auto *e) {
|
||||||
|
auto simple_expr = common::to_string(e);
|
||||||
|
|
||||||
LOG_DBG(
|
LOG_DBG("=== Processing expression requirement: {}",
|
||||||
"=== Processing expression requirement: {}", simple_expr);
|
simple_expr);
|
||||||
|
|
||||||
concept_model.add_statement(std::move(simple_expr));
|
concept_model.add_statement(std::move(simple_expr));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (req->getKind() == clang::concepts::Requirement::RK_Type) {
|
else if (req->getKind() == clang::concepts::Requirement::RK_Type) {
|
||||||
const auto *type_req =
|
util::apply_if_not_null(
|
||||||
llvm::dyn_cast<clang::concepts::TypeRequirement>(req);
|
llvm::dyn_cast<clang::concepts::TypeRequirement>(req),
|
||||||
|
[&concept_model, cpt](const auto *t) {
|
||||||
|
auto type_name = common::to_string(
|
||||||
|
t->getType()->getType(), cpt->getASTContext());
|
||||||
|
|
||||||
auto type_name = common::to_string(
|
LOG_DBG(
|
||||||
type_req->getType()->getType(), cpt->getASTContext());
|
"=== Processing type requirement: {}", type_name);
|
||||||
|
|
||||||
LOG_DBG("=== Processing type requirement: {}", type_name);
|
concept_model.add_statement(std::move(type_name));
|
||||||
|
});
|
||||||
concept_model.add_statement(std::move(type_name));
|
|
||||||
}
|
}
|
||||||
else if (req->getKind() ==
|
else if (req->getKind() ==
|
||||||
clang::concepts::Requirement::RK_Nested) {
|
clang::concepts::Requirement::RK_Nested) {
|
||||||
const auto *nested_req =
|
const auto *nested_req =
|
||||||
llvm::dyn_cast<clang::concepts::NestedRequirement>(req);
|
llvm::dyn_cast<clang::concepts::NestedRequirement>(req);
|
||||||
|
|
||||||
LOG_DBG("=== Processing nested requirement: {}",
|
if (nested_req != nullptr) {
|
||||||
common::to_string(nested_req->getConstraintExpr()));
|
util::apply_if_not_null(
|
||||||
|
nested_req->getConstraintExpr(), [](const auto *e) {
|
||||||
|
LOG_DBG("=== Processing nested requirement: {}",
|
||||||
|
common::to_string(e));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (req->getKind() ==
|
else if (req->getKind() ==
|
||||||
clang::concepts::Requirement::RK_Compound) {
|
clang::concepts::Requirement::RK_Compound) {
|
||||||
const auto *compound_req =
|
const auto *compound_req =
|
||||||
llvm::dyn_cast<clang::concepts::ExprRequirement>(req);
|
llvm::dyn_cast<clang::concepts::ExprRequirement>(req);
|
||||||
|
|
||||||
auto compound_expr = common::to_string(compound_req->getExpr());
|
if (compound_req != nullptr) {
|
||||||
|
const auto *compound_expr_ptr = compound_req->getExpr();
|
||||||
|
|
||||||
auto req_return_type = compound_req->getReturnTypeRequirement();
|
if (compound_expr_ptr != nullptr) {
|
||||||
|
auto compound_expr =
|
||||||
|
common::to_string(compound_expr_ptr);
|
||||||
|
|
||||||
if (!req_return_type.isEmpty()) {
|
auto req_return_type =
|
||||||
compound_expr = fmt::format("{{{}}} -> {}", compound_expr,
|
compound_req->getReturnTypeRequirement();
|
||||||
common::to_string(req_return_type.getTypeConstraint()));
|
|
||||||
|
if (!req_return_type.isEmpty()) {
|
||||||
|
compound_expr =
|
||||||
|
fmt::format("{{{}}} -> {}", compound_expr,
|
||||||
|
common::to_string(
|
||||||
|
req_return_type.getTypeConstraint()));
|
||||||
|
}
|
||||||
|
else if (compound_req->hasNoexceptRequirement()) {
|
||||||
|
compound_expr =
|
||||||
|
fmt::format("{{{}}} noexcept", compound_expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("=== Processing compound requirement: {}",
|
||||||
|
compound_expr);
|
||||||
|
|
||||||
|
concept_model.add_statement(std::move(compound_expr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (compound_req->hasNoexceptRequirement()) {
|
|
||||||
compound_expr =
|
|
||||||
fmt::format("{{{}}} noexcept", compound_expr);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_DBG(
|
|
||||||
"=== Processing compound requirement: {}", compound_expr);
|
|
||||||
|
|
||||||
concept_model.add_statement(std::move(compound_expr));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -609,7 +633,7 @@ void translation_unit_visitor::process_concept_specialization_relationships(
|
|||||||
type_name);
|
type_name);
|
||||||
}
|
}
|
||||||
else if (ta.getKind() == clang::TemplateArgument::Pack) {
|
else if (ta.getKind() == clang::TemplateArgument::Pack) {
|
||||||
if (ta.getPackAsArray().size() > 0 &&
|
if (!ta.getPackAsArray().empty() &&
|
||||||
ta.getPackAsArray().front().isPackExpansion()) {
|
ta.getPackAsArray().front().isPackExpansion()) {
|
||||||
const auto &pack_head =
|
const auto &pack_head =
|
||||||
ta.getPackAsArray().front().getAsType();
|
ta.getPackAsArray().front().getAsType();
|
||||||
@@ -917,7 +941,7 @@ bool translation_unit_visitor::process_template_parameters(
|
|||||||
ct.set_default_value("");
|
ct.set_default_value("");
|
||||||
ct.is_variadic(template_type_parameter->isParameterPack());
|
ct.is_variadic(template_type_parameter->isParameterPack());
|
||||||
|
|
||||||
if (template_type_parameter->getTypeConstraint()) {
|
if (template_type_parameter->getTypeConstraint() != nullptr) {
|
||||||
util::apply_if_not_null(
|
util::apply_if_not_null(
|
||||||
template_type_parameter->getTypeConstraint()
|
template_type_parameter->getTypeConstraint()
|
||||||
->getNamedConcept(),
|
->getNamedConcept(),
|
||||||
@@ -1483,7 +1507,7 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type->getAsCXXRecordDecl()) {
|
else if (type->getAsCXXRecordDecl() != nullptr) {
|
||||||
const auto target_id = common::to_id(*type->getAsCXXRecordDecl());
|
const auto target_id = common::to_id(*type->getAsCXXRecordDecl());
|
||||||
relationships.emplace_back(target_id, relationship_hint);
|
relationships.emplace_back(target_id, relationship_hint);
|
||||||
result = true;
|
result = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user