[clang-tools-extra] [clang-tidy] Add new check bugprone-tagged-union-member-count (PR #89925)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 07:00:27 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>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/89925 at github.com>
================
@@ -98,22 +124,21 @@ static bool greaterBySign(const llvm::APSInt &A, const llvm::APSInt &B) {
}
bool TaggedUnionMemberCountCheck::isCountingEnumLikeName(
- StringRef Name) const noexcept {
- if (llvm::any_of(ParsedCountingEnumPrefixes,
- [&Name](const StringRef &Prefix) -> bool {
- return Name.starts_with_insensitive(Prefix);
- }))
+ StringRef Name) const {
+ if (llvm::any_of(CountingEnumPrefixes, [Name](StringRef Prefix) -> bool {
+ return Name.starts_with_insensitive(Prefix);
+ }))
return true;
- if (llvm::any_of(ParsedCountingEnumSuffixes,
- [&Name](const StringRef &Suffix) -> bool {
- return Name.ends_with_insensitive(Suffix);
- }))
+ if (llvm::any_of(CountingEnumSuffixes, [Name](StringRef Suffix) -> bool {
+ return Name.ends_with_insensitive(Suffix);
+ }))
return true;
return false;
}
-size_t TaggedUnionMemberCountCheck::getNumberOfValidEnumValues(
- const EnumDecl *Ed) noexcept {
+std::size_t TaggedUnionMemberCountCheck::getNumberOfValidEnumValues(
+ const EnumDecl *ED,
+ const EnumConstantDecl *&OutCountingEnumConstantDecl) {
----------------
isuckatcs wrote:
```suggestion
std::pair<std::size_t, const EnumConstantDecl *> TaggedUnionMemberCountCheck::getNumberOfValidEnumValues(
const EnumDecl *ED) {
```
https://github.com/llvm/llvm-project/pull/89925
More information about the cfe-commits
mailing list