Fix clang-tidy warning after upgrading to clang-tidy-15

This commit is contained in:
Bartek Kryza
2023-03-02 00:33:28 +01:00
parent 884e021b9a
commit 464d80eca3
25 changed files with 114 additions and 78 deletions

View File

@@ -126,7 +126,7 @@ int class_::calculate_template_specialization_match(
{
int res{};
std::string left = name_and_ns();
const std::string left = name_and_ns();
// TODO: handle variadic templates
if ((name_and_ns() != full_name) ||
(templates().size() != other.templates().size())) {

View File

@@ -32,6 +32,8 @@ public:
class_element(
common::model::access_t scope, std::string name, std::string type);
virtual ~class_element() = default;
common::model::access_t access() const;
std::string name() const;
std::string type() const;

View File

@@ -28,7 +28,7 @@ public:
class_member(common::model::access_t access, const std::string &name,
const std::string &type);
virtual ~class_member() = default;
~class_member() override = default;
bool is_relationship() const;
void is_relationship(bool is_relationship);

View File

@@ -34,7 +34,7 @@ public:
class_method(common::model::access_t access, const std::string &name,
const std::string &type);
virtual ~class_method() = default;
~class_method() override = default;
bool is_pure_virtual() const;
void is_pure_virtual(bool is_pure_virtual);

View File

@@ -207,11 +207,11 @@ bool translation_unit_visitor::VisitClassTemplateSpecializationDecl(
// Process template specialization bases
process_class_bases(cls, template_specialization);
if (get_ast_local_id(cls->getSpecializedTemplate()->getID()).has_value())
const auto maybe_id =
get_ast_local_id(cls->getSpecializedTemplate()->getID());
if (maybe_id.has_value())
template_specialization.add_relationship(
{relationship_t::kInstantiation,
get_ast_local_id(cls->getSpecializedTemplate()->getID())
.value()});
{relationship_t::kInstantiation, maybe_id.value()});
if (diagram_.should_include(template_specialization)) {
const auto name = template_specialization.full_name(false);
@@ -615,10 +615,11 @@ void translation_unit_visitor::process_concept_specialization_relationships(
const auto cpt_name = cpt->getNameAsString();
if (!get_ast_local_id(cpt->getID()))
const auto maybe_id = get_ast_local_id(cpt->getID());
if (!maybe_id)
return;
auto target_id = get_ast_local_id(cpt->getID()).value();
const auto target_id = maybe_id.value();
std::vector<std::string> constrained_template_params;
@@ -2529,14 +2530,15 @@ bool translation_unit_visitor::build_template_instantiation_add_base_classes(
}
}
if (add_template_argument_as_base_class && ct.id()) {
const auto maybe_id = ct.id();
if (add_template_argument_as_base_class && maybe_id) {
LOG_DBG("Adding template argument as base class '{}'",
ct.to_string({}, false));
class_parent cp;
cp.set_access(access_t::kPublic);
cp.set_name(ct.to_string({}, false));
cp.set_id(ct.id().value());
cp.set_id(maybe_id.value());
tinst.add_parent(std::move(cp));
}
@@ -2735,24 +2737,24 @@ void translation_unit_visitor::resolve_local_to_global_ids()
for (const auto &cls : diagram().classes()) {
for (auto &rel : cls.get().relationships()) {
if (rel.type() == relationship_t::kInstantiation) {
const auto maybe_local_id = rel.destination();
if (get_ast_local_id(maybe_local_id)) {
const auto maybe_id = get_ast_local_id(rel.destination());
if (maybe_id) {
LOG_DBG("= Resolved instantiation destination from local "
"id {} to global id {}",
maybe_local_id, *get_ast_local_id(maybe_local_id));
rel.set_destination(*get_ast_local_id(maybe_local_id));
rel.destination(), *maybe_id);
rel.set_destination(*maybe_id);
}
}
}
}
for (const auto &cpt : diagram().concepts()) {
for (auto &rel : cpt.get().relationships()) {
const auto maybe_local_id = rel.destination();
if (get_ast_local_id(maybe_local_id)) {
const auto maybe_id = get_ast_local_id(rel.destination());
if (maybe_id) {
LOG_DBG("= Resolved instantiation destination from local "
"id {} to global id {}",
maybe_local_id, *get_ast_local_id(maybe_local_id));
rel.set_destination(*get_ast_local_id(maybe_local_id));
rel.destination(), *maybe_id);
rel.set_destination(*maybe_id);
}
}
}