[clang-tools-extra] [clang-tidy] Add new check bugprone-tagged-union-member-count (PR #89925)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 30 05:17:54 PDT 2024
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>,
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?= <tigbrcode at protonmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/89925 at github.com>
================
@@ -16,39 +16,74 @@ using namespace clang::ast_matchers;
namespace clang::tidy::bugprone {
-const char StrictModeOptionName[] = "StrictMode";
-const char EnableCountingEnumHeuristicOptionName[] =
+static constexpr llvm::StringLiteral StrictModeOptionName = "StrictMode";
+static constexpr llvm::StringLiteral EnableCountingEnumHeuristicOptionName =
"EnableCountingEnumHeuristic";
-const char CountingEnumPrefixesOptionName[] = "CountingEnumPrefixes";
-const char CountingEnumSuffixesOptionName[] = "CountingEnumSuffixes";
+static constexpr llvm::StringLiteral CountingEnumPrefixesOptionName =
+ "CountingEnumPrefixes";
+static constexpr llvm::StringLiteral CountingEnumSuffixesOptionName =
+ "CountingEnumSuffixes";
+
+static constexpr bool StrictModeOptionDefaultValue = false;
+static constexpr bool EnableCountingEnumHeuristicOptionDefaultValue = true;
+static constexpr llvm::StringLiteral CountingEnumPrefixesOptionDefaultValue =
+ "";
+static constexpr llvm::StringLiteral CountingEnumSuffixesOptionDefaultValue =
+ "count";
+
+static constexpr llvm::StringLiteral RootMatchBindName = "root";
+static constexpr llvm::StringLiteral UnionMatchBindName = "union";
+static constexpr llvm::StringLiteral TagMatchBindName = "tags";
+
+namespace {
+AST_MATCHER(FieldDecl, isUnion) {
+ const Type *T = Node.getType().getCanonicalType().getTypePtr();
+ assert(T);
+ return T->isUnionType();
+}
+
+AST_MATCHER(FieldDecl, isEnum) {
+ const Type *T = Node.getType().getCanonicalType().getTypePtr();
+ assert(T);
+ return T->isEnumeralType();
+}
----------------
tigbr wrote:
I was able to remove these AST_MATCHER macros by using the matchers that @whisperity has suggested.
https://github.com/llvm/llvm-project/pull/89925
More information about the cfe-commits
mailing list