From 4e461bd721c8b8d7a316f57f1a20ad63fda83836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 8 Aug 2024 11:08:24 +0200 Subject: [PATCH] enabled and mitigated `cppcoreguidelines-pro-type-static-cast-downcast` clang-tidy warnings (#6670) --- .clang-tidy | 3 ++- clang-tidy.md | 1 - gui/librarydialog.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 66e05bc8677..ad0afe924ea 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -19,8 +19,9 @@ Checks: > -openmp-*, -zircon-*, cert-err34-c, - google-explicit-constructor, + cppcoreguidelines-pro-type-static-cast-downcast, cppcoreguidelines-rvalue-reference-param-not-moved, + google-explicit-constructor, -bugprone-assignment-in-if-condition, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, diff --git a/clang-tidy.md b/clang-tidy.md index 55e68de2979..8ee7c36d714 100644 --- a/clang-tidy.md +++ b/clang-tidy.md @@ -135,7 +135,6 @@ To be evaluated (need to remove exclusion). `cppcoreguidelines-avoid-const-or-ref-data-members`
`cppcoreguidelines-macro-usage`
`cppcoreguidelines-pro-type-member-init`
-`cppcoreguidelines-pro-type-static-cast-downcast`
`cppcoreguidelines-prefer-member-initializer`
`cppcoreguidelines-misleading-capture-default-by-value`
`bugprone-argument-comment.CommentBoolLiterals`
diff --git a/gui/librarydialog.cpp b/gui/librarydialog.cpp index 4469940f417..c8c5f726584 100644 --- a/gui/librarydialog.cpp +++ b/gui/librarydialog.cpp @@ -87,7 +87,7 @@ CppcheckLibraryData::Function *LibraryDialog::currentFunction() QList selitems = mUi->functions->selectedItems(); if (selitems.count() != 1) return nullptr; - return static_cast(selitems.first())->function; + return dynamic_cast(selitems.first())->function; } void LibraryDialog::openCfg()