Skip to content

Commit 6e2d9a6

Browse files
committed
Update the description of the checks behavior to be more accurate
in the documentation, release notes and a test file.
1 parent f4d0b35 commit 6e2d9a6

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ Changes in existing checks
112112

113113
- Improved :doc:`bugprone-tagged-union-member-count
114114
<clang-tidy/checks/bugprone/tagged-union-member-count>` by fixing a false
115-
positive when typedefed enums or unions from system header files or the
116-
``std`` namespace are treated as the tag or the data part of a user-defined
115+
positive when enums or unions from system header files or the ``std``
116+
namespace are treated as the tag or the data part of a user-defined
117117
tagged union respectively.
118118

119119
- Improved :doc:`bugprone-unchecked-optional-access

clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ different from the number of data members inside the union.
99
A struct or a class is considered to be a tagged union if it has
1010
exactly one union data member and exactly one enum data member and
1111
any number of other data members that are neither unions or enums.
12-
The union and enum data members that are from system header files or
13-
the ``std`` namespace are not considered to make up the tagged union part
14-
of a user-defined tagged union type.
12+
Furthermore, the types of the union and the enum members must
13+
not come from a system header files or the ``std`` namespace
1514

1615
Example:
1716

@@ -45,7 +44,7 @@ system header files and the ``std`` namespace.
4544

4645
The ``pthread_mutex_t`` type may be defined as a union behind a ``typedef``,
4746
in which case the check could mistake this type as a user-defined tagged union.
48-
After all it has exactly one enum data member and exactly one union data member.
47+
After all, it has exactly one enum data member and exactly one union data member.
4948
To avoid false-positive cases originating from this, unions and enums from
5049
system headers and the ``std`` namespace are ignored when pinpointing the
5150
union part and the enum part of a potential user-defined tagged union.

clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ struct Name {\
149149
// CHECK-MESSAGES: :[[@LINE+1]]:44: warning: tagged union has more data members (4) than tags (3)
150150
DECLARE_TAGGED_UNION_STRUCT(Tags3, Union4, TaggedUnionStructFromMacro);
151151

152-
// Typedefed unions from system header files should be ignored when
152+
// Unions from system header files should be ignored when
153153
// we are trying to pinpoint the union part in a user-defined tagged union.
154154
#include <pthread.h>
155155

156156
// This should not be analyzed as a user-defined tagged union,
157-
// even though pthread_mutex_t may be declared as a typedefed union.
157+
// even though pthread_mutex_t could be a union.
158158
struct SystemTypedefedUnionDataMemberShouldBeIgnored {
159159
pthread_mutex_t Mutex;
160160
enum {

0 commit comments

Comments
 (0)