Applied readability-qualified-auto clang-tidy fixes

This commit is contained in:
Bartek Kryza
2022-12-21 17:39:08 +01:00
parent a907769c38
commit 75db32fdeb
5 changed files with 15 additions and 12 deletions

View File

@@ -64,7 +64,7 @@ model::namespace_ get_tag_namespace(const clang::TagDecl &declaration)
{
model::namespace_ ns;
auto *parent{declaration.getParent()};
const auto *parent{declaration.getParent()};
// First walk up to the nearest namespace, e.g. from nested class or enum
while (parent && !parent->isNamespace()) {
@@ -103,7 +103,7 @@ std::string get_tag_name(const clang::TagDecl &declaration)
std::deque<std::string> record_parent_names;
record_parent_names.push_front(base_name);
auto *cls_parent{declaration.getParent()};
const auto *cls_parent{declaration.getParent()};
while (cls_parent->isRecord()) {
auto parent_name =
static_cast<const clang::RecordDecl *>(cls_parent)

View File

@@ -40,7 +40,7 @@ bool decorated_element::skip_relationship() const
std::pair<relationship_t, std::string>
decorated_element::get_relationship() const
{
for (auto &d : decorators_)
for (const auto &d : decorators_)
if (std::dynamic_pointer_cast<decorators::association>(d))
return {relationship_t::kAssociation,
std::dynamic_pointer_cast<decorators::relationship>(d)

View File

@@ -87,8 +87,9 @@ void clang_visitor::visit(
clang::dyn_cast<TParamCommandComment>(block), traits, cmt);
}
else if (block_kind == Comment::BlockCommandCommentKind) {
auto *command = clang::dyn_cast<BlockCommandComment>(block);
auto command_info = traits.getCommandInfo(command->getCommandID());
const auto *command = clang::dyn_cast<BlockCommandComment>(block);
const auto *command_info =
traits.getCommandInfo(command->getCommandID());
if (command_info->IsBlockCommand && command_info->NumArgs == 0) {
// Visit block command with a single text argument, e.g.:
@@ -125,7 +126,7 @@ void clang_visitor::visit_block_command(
std::string command_text;
for (auto paragraph_it = command->child_begin();
for (const auto *paragraph_it = command->child_begin();
paragraph_it != command->child_end(); ++paragraph_it) {
if ((*paragraph_it)->getCommentKind() ==
@@ -156,7 +157,8 @@ void clang_visitor::visit_param_command(
const auto name = command->getParamNameAsWritten().str();
for (auto it = command->child_begin(); it != command->child_end(); ++it) {
for (const auto *it = command->child_begin(); it != command->child_end();
++it) {
if ((*it)->getCommentKind() == Comment::ParagraphCommentKind) {
visit_paragraph(
@@ -187,7 +189,8 @@ void clang_visitor::visit_tparam_command(
const auto name = command->getParamNameAsWritten().str();
for (auto it = command->child_begin(); it != command->child_end(); ++it) {
for (const auto *it = command->child_begin(); it != command->child_end();
++it) {
if ((*it)->getCommentKind() == Comment::ParagraphCommentKind) {
visit_paragraph(
clang::dyn_cast<ParagraphComment>(*it), traits, description);
@@ -212,7 +215,7 @@ void clang_visitor::visit_paragraph(
using clang::comments::Comment;
using clang::comments::TextComment;
for (auto text_it = paragraph->child_begin();
for (const auto *text_it = paragraph->child_begin();
text_it != paragraph->child_end(); ++text_it) {
if ((*text_it)->getCommentKind() == Comment::TextCommentKind) {

View File

@@ -62,7 +62,7 @@ decorator_toks decorator::tokenize(const std::string &label, std::string_view c)
decorator_toks res;
res.label = label;
size_t pos{};
auto it = c.begin();
const auto *it = c.begin();
std::advance(it, label.size());
if (*it == ':') {

View File

@@ -238,7 +238,7 @@ void translation_unit_visitor::process_class_children(
void translation_unit_visitor::process_class_bases(
const clang::CXXRecordDecl &cls, found_relationships_t &relationships)
{
for (auto &base : cls.bases()) {
for (const auto &base : cls.bases()) {
find_relationships(base.getType(), relationships);
}
}
@@ -336,7 +336,7 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
relationships.emplace_back(
common::to_id(*type->getAs<clang::EnumType>()), relationship_hint);
}
else if (auto *template_specialization_type =
else if (const auto *template_specialization_type =
type->getAs<clang::TemplateSpecializationType>()) {
if (template_specialization_type != nullptr) {
if (template_specialization_type->isTypeAlias())