Updated to clang-tidy-17

This commit is contained in:
Bartek Kryza
2024-06-04 23:49:42 +02:00
parent 50851531f9
commit a6a92c3543
7 changed files with 21 additions and 20 deletions

View File

@@ -163,7 +163,7 @@ format:
.PHONY: debug_tidy .PHONY: debug_tidy
tidy: debug_tidy tidy: debug_tidy
run-clang-tidy-15 -extra-arg=-Wno-unknown-warning-option -j $(NUMPROC) -p debug_tidy ./src run-clang-tidy-17 -extra-arg=-Wno-unknown-warning-option -j $(NUMPROC) -p debug_tidy ./src
.PHONY: check-formatting .PHONY: check-formatting
check-formatting: check-formatting:

View File

@@ -917,7 +917,7 @@ void translation_unit_visitor::process_record_parent(
std::string destination_multiplicity_str{}; std::string destination_multiplicity_str{};
if (destination_multiplicity.has_value()) { if (destination_multiplicity.has_value()) {
destination_multiplicity_str = destination_multiplicity_str =
std::to_string(*destination_multiplicity); // NOLINT std::to_string(*destination_multiplicity);
} }
parent_class.value().add_relationship( parent_class.value().add_relationship(
@@ -1673,8 +1673,8 @@ void translation_unit_visitor::add_relationships(class_ &c,
} }
if (!mulitplicity_provided_in_comment && if (!mulitplicity_provided_in_comment &&
field.destination_multiplicity().has_value()) { field.destination_multiplicity().has_value()) {
r.set_multiplicity_destination(std::to_string( r.set_multiplicity_destination(
*field.destination_multiplicity())); // NOLINT std::to_string(*field.destination_multiplicity()));
} }
r.set_style(field.style_spec()); r.set_style(field.style_spec());

View File

@@ -22,7 +22,6 @@
#include "class_diagram/generators/plantuml/class_diagram_generator.h" #include "class_diagram/generators/plantuml/class_diagram_generator.h"
#include "cli/cli_handler.h" #include "cli/cli_handler.h"
#include "common/compilation_database.h" #include "common/compilation_database.h"
#include "common/generators/generators.h"
#include "common/model/diagram_filter.h" #include "common/model/diagram_filter.h"
#include "config/config.h" #include "config/config.h"
#include "include_diagram/generators/json/include_diagram_generator.h" #include "include_diagram/generators/json/include_diagram_generator.h"

View File

@@ -684,8 +684,9 @@ std::vector<common::id_t> translation_unit_visitor::get_parent_package_ids(
std::optional<common::id_t> parent_id = id; std::optional<common::id_t> parent_id = id;
while (parent_id.has_value()) { while (parent_id.has_value()) {
parent_ids.push_back(parent_id.value()); const auto pid = parent_id.value(); // NOLINT
auto parent = this->diagram().get(parent_id.value()); parent_ids.push_back(pid);
auto parent = this->diagram().get(pid);
if (parent) if (parent)
parent_id = parent.value().parent_element_id(); parent_id = parent.value().parent_element_id();
else else

View File

@@ -158,7 +158,7 @@ void call_expression_context::enter_lambda_expression(common::id_t id)
assert(id.value() != 0); assert(id.value() != 0);
current_lambda_caller_id_.push(id); current_lambda_caller_id_.emplace(id);
} }
void call_expression_context::leave_lambda_expression() void call_expression_context::leave_lambda_expression()
@@ -182,7 +182,7 @@ clang::IfStmt *call_expression_context::current_ifstmt() const
void call_expression_context::enter_ifstmt(clang::IfStmt *stmt) void call_expression_context::enter_ifstmt(clang::IfStmt *stmt)
{ {
if_stmt_stack_.push(stmt); if_stmt_stack_.emplace(stmt);
} }
void call_expression_context::leave_ifstmt() void call_expression_context::leave_ifstmt()
@@ -197,7 +197,7 @@ void call_expression_context::enter_elseifstmt(clang::IfStmt *stmt)
{ {
assert(current_ifstmt() != nullptr); assert(current_ifstmt() != nullptr);
elseif_stmt_stacks_[current_ifstmt()].push(stmt); elseif_stmt_stacks_[current_ifstmt()].emplace(stmt);
} }
clang::IfStmt *call_expression_context::current_elseifstmt() const clang::IfStmt *call_expression_context::current_elseifstmt() const
@@ -221,7 +221,7 @@ clang::Stmt *call_expression_context::current_loopstmt() const
void call_expression_context::enter_loopstmt(clang::Stmt *stmt) void call_expression_context::enter_loopstmt(clang::Stmt *stmt)
{ {
loop_stmt_stack_.push(stmt); loop_stmt_stack_.emplace(stmt);
} }
void call_expression_context::leave_loopstmt() void call_expression_context::leave_loopstmt()
@@ -241,12 +241,12 @@ call_expression_context::current_callexpr() const
void call_expression_context::enter_callexpr(clang::CallExpr *expr) void call_expression_context::enter_callexpr(clang::CallExpr *expr)
{ {
call_expr_stack_.push(expr); call_expr_stack_.emplace(expr);
} }
void call_expression_context::enter_callexpr(clang::CXXConstructExpr *expr) void call_expression_context::enter_callexpr(clang::CXXConstructExpr *expr)
{ {
call_expr_stack_.push(expr); call_expr_stack_.emplace(expr);
} }
void call_expression_context::leave_callexpr() void call_expression_context::leave_callexpr()
@@ -266,7 +266,7 @@ clang::Stmt *call_expression_context::current_trystmt() const
void call_expression_context::enter_trystmt(clang::Stmt *stmt) void call_expression_context::enter_trystmt(clang::Stmt *stmt)
{ {
try_stmt_stack_.push(stmt); try_stmt_stack_.emplace(stmt);
} }
void call_expression_context::leave_trystmt() void call_expression_context::leave_trystmt()
@@ -285,7 +285,7 @@ clang::SwitchStmt *call_expression_context::current_switchstmt() const
void call_expression_context::enter_switchstmt(clang::SwitchStmt *stmt) void call_expression_context::enter_switchstmt(clang::SwitchStmt *stmt)
{ {
switch_stmt_stack_.push(stmt); switch_stmt_stack_.emplace(stmt);
} }
void call_expression_context::leave_switchstmt() void call_expression_context::leave_switchstmt()
@@ -306,7 +306,7 @@ call_expression_context::current_conditionaloperator() const
void call_expression_context::enter_conditionaloperator( void call_expression_context::enter_conditionaloperator(
clang::ConditionalOperator *stmt) clang::ConditionalOperator *stmt)
{ {
conditional_operator_stack_.push(stmt); conditional_operator_stack_.emplace(stmt);
} }
void call_expression_context::leave_conditionaloperator() void call_expression_context::leave_conditionaloperator()

View File

@@ -1930,15 +1930,16 @@ std::string translation_unit_visitor::make_lambda_name(
const auto location = cls->getLocation(); const auto location = cls->getLocation();
const std::string source_location{lambda_source_location(location)}; const std::string source_location{lambda_source_location(location)};
if (context().lambda_caller_id().has_value()) { const auto maybe_lambda_caller_id = context().lambda_caller_id();
if (maybe_lambda_caller_id.has_value()) {
// Parent is also a lambda (this id points to a lambda operator()) // Parent is also a lambda (this id points to a lambda operator())
std::string parent_lambda_class_name{"()"}; std::string parent_lambda_class_name{"()"};
if (diagram().get_participant<model::method>( if (diagram().get_participant<model::method>(
context().lambda_caller_id().value())) { // NOLINT maybe_lambda_caller_id.value())) {
auto parent_lambda_class_id = auto parent_lambda_class_id =
diagram() diagram()
.get_participant<model::method>( .get_participant<model::method>(
context().lambda_caller_id().value()) // NOLINT maybe_lambda_caller_id.value())
.value() .value()
.class_id(); .class_id();

View File

@@ -164,7 +164,7 @@ template <typename T, typename S>
std::unique_ptr<T> unique_pointer_cast(std::unique_ptr<S> &&p) noexcept std::unique_ptr<T> unique_pointer_cast(std::unique_ptr<S> &&p) noexcept
{ {
if (T *const converted = dynamic_cast<T *>(p.get())) { if (T *const converted = dynamic_cast<T *>(p.get())) {
p.release(); // NOLINT std::move(p).release(); // NOLINT
return std::unique_ptr<T>{converted}; return std::unique_ptr<T>{converted};
} }