From 9e8871ef062266e0f29904fd2cf8128309791a35 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 17 Apr 2024 15:27:35 +0200 Subject: [PATCH] Shush cppcheck, you don't know your type traits (but we run an outdated you, so I forgive you) https://godbolt.org/z/Wo7dPqvs3 ```c++ #include #include #include #include using VariantType = std::variant; template inline constexpr bool always_false_v = false; constexpr void test_type(auto&& arg) { using T = std::decay_t; if constexpr (std::is_same_v) { fmt::print(FMT_COMPILE("Hey there unsigned! cppcheck thought you wouldn't be here\n")); } else if constexpr (std::is_same_v) { fmt::print(FMT_COMPILE("Hello integer, how are you?\n")); } else { static_assert(always_false_v, "non-exhaustive visitor!"); } } constexpr void test_variant_type(const VariantType& arg) { std::visit( [](auto&& arg) { using T = std::decay_t; if constexpr (std::is_same_v) { fmt::print(FMT_COMPILE("Hello integer, how are you?\n")); } else if constexpr (std::is_same_v) { fmt::print(FMT_COMPILE("Hey there unsigned! cppcheck thought you wouldn't be here\n")); } else { static_assert(always_false_v, "non-exhaustive visitor!"); } }, arg); } int main() { int i = 10; test_type(i); unsigned u = 10; test_type(u); fmt::print("Variant\n"); auto iv = VariantType(i); auto uv = VariantType(u); test_variant_type(iv); test_variant_type(uv); } ``` --- src/utilities/data/Attribute.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utilities/data/Attribute.cpp b/src/utilities/data/Attribute.cpp index 4ead7c33c4b..35bb574a5bf 100644 --- a/src/utilities/data/Attribute.cpp +++ b/src/utilities/data/Attribute.cpp @@ -698,6 +698,8 @@ namespace detail { return arg; } else if constexpr (std::is_same_v) { return arg; + // cppcheck-suppress identicalConditionAfterEarlyExit + // cppcheck-suppress multiCondition } else if constexpr (std::is_same_v) { return arg; } else if constexpr (std::is_same_v) {