[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 2 06:26:36 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>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/89925 at github.com>
https://github.com/whisperity requested changes to this pull request.
I found a very convoluted and somewhat silly edge case where I was able to defeat the matchers to make them produce a match in a position where it is clearly not intended. So the matchers will need to be given some thought, my idea is to have them constricted in a way to report only into non-implicit code, but perhaps this needs some more elaboration.
Lambdas implicitly compile down to an unnamed `CXXRecordDecl`, and if you have captures in a lambda, they become (unnamed) fields of this class.
https://godbolt.org/z/rvfY5K18T
```cpp
enum E { A };
union U {
int A;
};
int main() {
enum E e;
union U u;
auto L = [e, u] () {};
}
```
```
Match #1:
<source>:9:14: note: "root" binds here
9 | auto L = [e, u] () {};
| ^
<source>:9:15: note: "tags" binds here
9 | auto L = [e, u] () {};
| ^
<source>:9:18: note: "union" binds here
9 | auto L = [e, u] () {};
| ^
```
https://github.com/llvm/llvm-project/pull/89925
More information about the cfe-commits
mailing list