Skip to content

Commit 6d26be2

Browse files
Merge branch 'main' into masked-store
2 parents f5aed1f + 30728eb commit 6d26be2

File tree

324 files changed

+8383
-4175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+8383
-4175
lines changed

clang-tools-extra/clang-tidy/.clang-tidy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Checks: >
1616
-modernize-use-trailing-return-type,
1717
performance-*,
1818
-performance-enum-size,
19-
-performance-move-const-arg,
2019
-performance-no-int-to-ptr,
2120
-performance-type-promotion-in-math-fn,
2221
-performance-unnecessary-value-param,
@@ -38,3 +37,7 @@ Checks: >
3837
-readability-static-definition-in-anonymous-namespace,
3938
-readability-suspicious-call-argument,
4039
-readability-use-anyofallof
40+
41+
CheckOptions:
42+
- key: performance-move-const-arg.CheckTriviallyCopyableMove
43+
value: false

clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,15 @@ void TaggedUnionMemberCountCheck::storeOptions(
105105

106106
void TaggedUnionMemberCountCheck::registerMatchers(MatchFinder *Finder) {
107107

108-
auto UnionField = fieldDecl(hasType(qualType(
109-
hasCanonicalType(recordType(hasDeclaration(recordDecl(isUnion())))))));
108+
auto NotFromSystemHeaderOrStdNamespace =
109+
unless(anyOf(isExpansionInSystemHeader(), isInStdNamespace()));
110110

111-
auto EnumField = fieldDecl(hasType(
112-
qualType(hasCanonicalType(enumType(hasDeclaration(enumDecl()))))));
111+
auto UnionField =
112+
fieldDecl(hasType(qualType(hasCanonicalType(recordType(hasDeclaration(
113+
recordDecl(isUnion(), NotFromSystemHeaderOrStdNamespace)))))));
114+
115+
auto EnumField = fieldDecl(hasType(qualType(hasCanonicalType(
116+
enumType(hasDeclaration(enumDecl(NotFromSystemHeaderOrStdNamespace)))))));
113117

114118
auto HasOneUnionField = fieldCountOfKindIsOne(UnionField, UnionMatchBindName);
115119
auto HasOneEnumField = fieldCountOfKindIsOne(EnumField, TagMatchBindName);

clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
132132
hasAncestor(functionDecl().bind("func")),
133133
hasAncestor(functionDecl(
134134
isDefinition(), equalsBoundNode("func"), ToParam,
135-
unless(anyOf(isDeleted(),
136-
hasDescendant(std::move(ForwardCallMatcher))))))),
135+
unless(anyOf(isDeleted(), hasDescendant(ForwardCallMatcher)))))),
137136
this);
138137
}
139138

clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) {
6767
hasParent(fieldDecl(
6868
hasParent(recordDecl(isExternCContext())))),
6969
hasAncestor(functionDecl(isExternC())))),
70-
std::move(IgnoreStringArrayIfNeededMatcher))
70+
IgnoreStringArrayIfNeededMatcher)
7171
.bind("typeloc"),
7272
this);
7373
}

clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void UseStdNumbersCheck::registerMatchers(MatchFinder *const Finder) {
319319

320320
Finder->addMatcher(
321321
expr(
322-
anyOfExhaustive(std::move(ConstantMatchers)),
322+
anyOfExhaustive(ConstantMatchers),
323323
unless(hasParent(explicitCastExpr(hasDestinationType(isFloating())))),
324324
hasType(qualType(hasCanonicalTypeUnqualified(
325325
anyOf(qualType(asString("float")).bind("float"),

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def print_profile_data(aggregated_data: Dict[str, float]) -> None:
236236
checkers.items(), key=lambda x: x[1]["user"] + x[1]["sys"], reverse=True
237237
)
238238

239-
def print_stderr(*args, **kwargs) -> None:
239+
def print_stderr(*args: Any, **kwargs: Any) -> None:
240240
print(*args, file=sys.stderr, **kwargs)
241241

242242
print_stderr(

clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void UseRangesCheck::registerMatchers(MatchFinder *Finder) {
149149
}
150150
Finder->addMatcher(
151151
callExpr(
152-
callee(functionDecl(hasAnyName(std::move(Names)))
152+
callee(functionDecl(hasAnyName(Names))
153153
.bind((FuncDecl + Twine(Replacers.size() - 1).str()))),
154154
ast_matchers::internal::DynTypedMatcher::constructVariadic(
155155
ast_matchers::internal::DynTypedMatcher::VO_AnyOf,

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ Changes in existing checks
142142
<clang-tidy/checks/bugprone/signed-char-misuse>` check by fixing
143143
false positives on C23 enums with the fixed underlying type of signed char.
144144

145+
- Improved :doc:`bugprone-tagged-union-member-count
146+
<clang-tidy/checks/bugprone/tagged-union-member-count>` by fixing a false
147+
positive when enums or unions from system header files or the ``std``
148+
namespace are treated as the tag or the data part of a user-defined
149+
tagged union respectively.
150+
145151
- Improved :doc:`bugprone-unhandled-self-assignment
146152
<clang-tidy/checks/bugprone/unhandled-self-assignment>` check by adding
147153
an additional matcher that generalizes the copy-and-swap idiom pattern

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +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+
Furthermore, the types of the union and the enum members must
13+
not come from system header files nor the ``std`` namespace.
1214

1315
Example:
1416

@@ -28,6 +30,25 @@ Example:
2830
} Data;
2931
};
3032
33+
The following example illustrates the exception for unions and enums from
34+
system header files and the ``std`` namespace.
35+
36+
.. code-block:: c++
37+
38+
#include <pthread.h>
39+
40+
struct NotTaggedUnion {
41+
enum MyEnum { MyEnumConstant1, MyEnumConstant2 } En;
42+
pthread_mutex_t Mutex;
43+
};
44+
45+
The ``pthread_mutex_t`` type may be defined as a union behind a ``typedef``,
46+
in which case the check could mistake this type as a user-defined tagged union.
47+
After all, it has exactly one enum data member and exactly one union data member.
48+
To avoid false-positive cases originating from this, unions and enums from
49+
system headers and the ``std`` namespace are ignored when pinpointing the
50+
union part and the enum part of a potential user-defined tagged union.
51+
3152
How enum constants are counted
3253
------------------------------
3354

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+
};

0 commit comments

Comments
 (0)