From e7dd9cd793d6f771366ddc4fa6645c087ddc8d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 31 Aug 2023 09:04:51 +0200 Subject: [PATCH] enabled `readability-use-anyofallof` clang-tidy warning / added more checks to evaluate (#5339) --- .clang-tidy | 3 +-- clang-tidy.md | 12 +++++++++--- lib/astutils.cpp | 1 + lib/valueflow.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 96c8908f0..7617f792e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -66,8 +66,7 @@ Checks: > -readability-magic-numbers, -readability-redundant-access-specifiers, -readability-suspicious-call-argument, - -readability-uppercase-literal-suffix, - -readability-use-anyofallof + -readability-uppercase-literal-suffix WarningsAsErrors: '*' HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h' CheckOptions: diff --git a/clang-tidy.md b/clang-tidy.md index b85031ac2..ba7c7d611 100644 --- a/clang-tidy.md +++ b/clang-tidy.md @@ -87,9 +87,6 @@ We intentionally use this. Leads to lots of "false positives". This seem to enforce a coding guidelines of certain codebases. -`readability-use-anyofallof`
- -We currently don't even apply our own `useStlAlgorithm` findings. `bugprone-easily-swappable-parameters`
@@ -146,6 +143,15 @@ To be evaluated (need to remove exclusion). `cppcoreguidelines-missing-std-forward`
`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`
+`cert-err33-c`
+`google-readability-namespace-comments`
+`cppcoreguidelines-special-member-functions`
To be evaluated (need to enable explicitly). diff --git a/lib/astutils.cpp b/lib/astutils.cpp index d4232de0b..1be4c9be5 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -984,6 +984,7 @@ bool isAliasOf(const Token *tok, nonneg int varid, bool* inconclusive) { if (tok->varId() == varid) return false; + // NOLINTNEXTLINE(readability-use-anyofallof) - TODO: fix this / also Cppcheck false negative for (const ValueFlow::Value &val : tok->values()) { if (!val.isLocalLifetimeValue()) continue; diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 6a249fb2c..ea30d13c7 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3055,12 +3055,11 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer { } bool isGlobal() const override { - for (const auto&p:getVars()) { + const auto& vars = getVars(); + return std::any_of(vars.cbegin(), vars.cend(), [] (const std::pair& p) { const Variable* var = p.second; - if (!var->isLocal() && !var->isArgument() && !var->isConst()) - return true; - } - return false; + return !var->isLocal() && !var->isArgument() && !var->isConst(); + }); } bool lowerToPossible() override { @@ -5839,6 +5838,7 @@ static bool intersects(const C1& c1, const C2& c2) { if (c1.size() > c2.size()) return intersects(c2, c1); + // NOLINTNEXTLINE(readability-use-anyofallof) - TODO: fix if possible / also Cppcheck false negative for (auto&& x : c1) { if (c2.find(x) != c2.end()) return true;