Applying bugprone-narrowing-conversions clang-tidy fixes

This commit is contained in:
Bartek Kryza
2022-12-21 18:05:45 +01:00
parent 5d8f31dbe6
commit 14128374ef
5 changed files with 13 additions and 7 deletions

View File

@@ -34,6 +34,7 @@ Checks: >-
-readability-inconsistent-declaration-parameter-name, -readability-inconsistent-declaration-parameter-name,
-readability-identifier-naming, -readability-identifier-naming,
-readability-redundant-smartptr-get, -readability-redundant-smartptr-get,
-readability-convert-member-functions-to-static,
-darwin*, -darwin*,
-zircon* -zircon*
WarningsAsErrors: '*' WarningsAsErrors: '*'

View File

@@ -194,10 +194,14 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
std::string destination; std::string destination;
try { try {
destination = r.destination(); auto target_element = m_model.get(r.destination());
if (!target_element.has_value())
throw error::uml_alias_missing{
fmt::format("Missing element in the model for ID: {}",
r.destination())};
destination = target_element.value().full_name(false);
// TODO: Refactor destination to a namespace qualified entity
// name
if (util::starts_with(destination, std::string{"::"})) if (util::starts_with(destination, std::string{"::"}))
destination = destination.substr(2, destination.size()); destination = destination.substr(2, destination.size());

View File

@@ -1409,7 +1409,8 @@ std::unique_ptr<class_> translation_unit_visitor::
template_instantiation.set_name(template_decl->getNameAsString()); template_instantiation.set_name(template_decl->getNameAsString());
template_instantiation.set_namespace(ns); template_instantiation.set_namespace(ns);
template_instantiation.set_id(template_decl->getID() + template_instantiation.set_id(template_decl->getID() +
(std::hash<std::string>{}(full_template_specialization_name) >> 4)); static_cast<id_t>(
std::hash<std::string>{}(full_template_specialization_name) >> 4u));
build_template_instantiation_process_template_arguments(parent, build_template_instantiation_process_template_arguments(parent,
template_base_params, template_base_params,
@@ -1661,7 +1662,7 @@ void translation_unit_visitor::
const std::string &full_template_specialization_name, const std::string &full_template_specialization_name,
const clang::TemplateDecl *template_decl) const clang::TemplateDecl *template_decl)
{ {
auto arg_index = 0U; auto arg_index = 0;
for (const auto &arg : template_args) { for (const auto &arg : template_args) {
const auto argument_kind = arg.getKind(); const auto argument_kind = arg.getKind();
template_parameter argument; template_parameter argument;

View File

@@ -244,7 +244,7 @@ bool is_subexpr_of(const clang::Stmt *parent_stmt, const clang::Stmt *sub_stmt)
template <> id_t to_id(const std::string &full_name) template <> id_t to_id(const std::string &full_name)
{ {
return std::hash<std::string>{}(full_name) >> 3; return static_cast<id_t>(std::hash<std::string>{}(full_name) >> 3u);
} }
template <> id_t to_id(const clang::NamespaceDecl &declaration) template <> id_t to_id(const clang::NamespaceDecl &declaration)

View File

@@ -91,7 +91,7 @@ void clang_visitor::visit(
const auto *command_info = const auto *command_info =
traits.getCommandInfo(command->getCommandID()); traits.getCommandInfo(command->getCommandID());
if (command_info->IsBlockCommand && command_info->NumArgs == 0) { if (command_info->IsBlockCommand && command_info->NumArgs == 0u) {
// Visit block command with a single text argument, e.g.: // Visit block command with a single text argument, e.g.:
// \brief text // \brief text
// \todo text // \todo text