File tree Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -9,9 +9,8 @@ different from the number of data members inside the union.
99A struct or a class is considered to be a tagged union if it has
1010exactly one union data member and exactly one enum data member and
1111any 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
1615Example:
1716
@@ -45,7 +44,7 @@ system header files and the ``std`` namespace.
4544
4645The ``pthread_mutex_t `` type may be defined as a union behind a ``typedef ``,
4746in 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.
4948To avoid false-positive cases originating from this, unions and enums from
5049system headers and the ``std `` namespace are ignored when pinpointing the
5150union part and the enum part of a potential user-defined tagged union.
Original file line number Diff line number Diff 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)
150150DECLARE_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.
158158struct SystemTypedefedUnionDataMemberShouldBeIgnored {
159159 pthread_mutex_t Mutex ;
160160 enum {
You can’t perform that action at this time.
0 commit comments