[clang-tools-extra] [clang-tidy] Add new check bugprone-tagged-union-member-count (PR #89925)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 23 02:06:12 PDT 2024
º×üm
½ÈSÍÑ¡Û
ɤ¶(Êzè¶æj)\¢c²Æ xÈ©$è[梸?[æþYoèç-þ¥ÿ=÷n`ØnmÊ&
================
@@ -0,0 +1,216 @@
+.. title:: clang-tidy - bugprone-tagged-union-member-count
+
+bugprone-tagged-union-member-count
+==================================
+
+Gives warnings for tagged unions, where the number of tags is
+different from the number of data members inside the union.
+
+A struct or a class is considered to be a tagged union if it has
+exactly one union data member and exactly one enum data member and
+any number of other data members that are neither unions or enums.
+
+Example
+-------
+
+.. code-block:: c++
+
+ enum tags {
+ tag1,
+ tag2,
+ };
+
+ struct taggedUnion { // warning: Tagged union has more data members (3) than tags (2)! [bugprone-tagged-union-member-count]
----------------
whisperity wrote:
```suggestion
struct taggedUnion { // warning: Tagged union has more data members (3) than tags (2)
```
https://github.com/llvm/llvm-project/pull/89925
More information about the cfe-commits
mailing list