Skip to content

Commit 5f888b4

Browse files
committed
Create test case for when the enum or the union comes from the std namespace but
not a system header.
1 parent bad89cb commit 5f888b4

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#define __SIZEOF_PTHREAD_MUTEX_T 40
2+
3+
namespace std {
4+
typedef union {
5+
struct __pthread_mutex_s {
6+
int __lock;
7+
unsigned int __count;
8+
} __data;
9+
char __size[__SIZEOF_PTHREAD_MUTEX_T];
10+
long int __align;
11+
} pthread_mutex_t;
12+
};

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %check_clang_tidy -std=c++98-or-later %s bugprone-tagged-union-member-count %t -- -- \
2+
// RUN: -I%S/Inputs/tagged-union-member-count \
23
// RUN: -isystem %S/Inputs/tagged-union-member-count/system
34
// Test check with C++ features
45

@@ -322,3 +323,13 @@ struct SystemTypedefedUnionDataMemberShouldBeIgnored {
322323
MyEnum
323324
} EnumField;
324325
};
326+
327+
// Filter when union or enum comes from the std namespace but not a system header
328+
#include "stdnamespace.h"
329+
330+
struct StdNameSpaceUnionDataMemberShouldBeIgnored {
331+
std::pthread_mutex_t Mutex;
332+
enum {
333+
MyEnum
334+
} EnumField;
335+
};

0 commit comments

Comments
 (0)