Skip to content

Commit 74f131e

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web' (#4)
CONFLICT (content): Merge conflict in clang/test/SemaOpenCL/invalid-kernel-attrs.cl
2 parents f4f64de + cd2f65b commit 74f131e

File tree

838 files changed

+30022
-24161
lines changed

Some content is hidden

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

838 files changed

+30022
-24161
lines changed

clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ SymbolIndexManager::search(llvm::StringRef Identifier,
149149
rank(MatchedSymbols, FileName);
150150
// Strip signals, they are no longer needed.
151151
std::vector<SymbolInfo> Res;
152+
Res.reserve(MatchedSymbols.size());
152153
for (auto &SymAndSig : MatchedSymbols)
153154
Res.push_back(std::move(SymAndSig.Symbol));
154155
return Res;

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ namespace bugprone {
2121

2222
static internal::Matcher<Stmt>
2323
loopEndingStmt(internal::Matcher<Stmt> Internal) {
24-
return stmt(anyOf(breakStmt(Internal), returnStmt(Internal),
25-
gotoStmt(Internal), cxxThrowExpr(Internal),
26-
callExpr(Internal, callee(functionDecl(isNoReturn())))));
24+
return stmt(anyOf(
25+
mapAnyOf(breakStmt, returnStmt, gotoStmt, cxxThrowExpr).with(Internal),
26+
callExpr(Internal, callee(functionDecl(isNoReturn())))));
2727
}
2828

2929
/// Return whether `Var` was changed in `LoopStmt`.
@@ -122,8 +122,8 @@ void InfiniteLoopCheck::registerMatchers(MatchFinder *Finder) {
122122
unless(hasBody(hasDescendant(
123123
loopEndingStmt(forFunction(equalsBoundNode("func")))))));
124124

125-
Finder->addMatcher(stmt(anyOf(whileStmt(LoopCondition), doStmt(LoopCondition),
126-
forStmt(LoopCondition)))
125+
Finder->addMatcher(mapAnyOf(whileStmt, doStmt, forStmt)
126+
.with(LoopCondition)
127127
.bind("loop-stmt"),
128128
this);
129129
}

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

+10-24
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,20 @@ void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) {
5959
if (getLangOpts().CPlusPlus) {
6060
// Check for `CON54-CPP`
6161
Finder->addMatcher(
62-
ifStmt(
63-
allOf(HasWaitDescendantCpp,
64-
unless(anyOf(hasDescendant(ifStmt(HasWaitDescendantCpp)),
65-
hasDescendant(whileStmt(HasWaitDescendantCpp)),
66-
hasDescendant(forStmt(HasWaitDescendantCpp)),
67-
hasDescendant(doStmt(HasWaitDescendantCpp)))))
68-
69-
),
62+
ifStmt(HasWaitDescendantCpp,
63+
unless(hasDescendant(mapAnyOf(ifStmt, whileStmt, forStmt, doStmt)
64+
.with(HasWaitDescendantCpp)))),
7065
this);
7166
} else {
7267
// Check for `CON36-C`
7368
Finder->addMatcher(
74-
ifStmt(
75-
allOf(HasWaitDescendantC,
76-
unless(anyOf(hasDescendant(ifStmt(HasWaitDescendantC)),
77-
hasDescendant(whileStmt(HasWaitDescendantC)),
78-
hasDescendant(forStmt(HasWaitDescendantC)),
79-
hasDescendant(doStmt(HasWaitDescendantC)),
80-
hasParent(whileStmt()),
81-
hasParent(compoundStmt(hasParent(whileStmt()))),
82-
hasParent(forStmt()),
83-
hasParent(compoundStmt(hasParent(forStmt()))),
84-
hasParent(doStmt()),
85-
hasParent(compoundStmt(hasParent(doStmt())))))
86-
87-
))
88-
89-
,
69+
ifStmt(HasWaitDescendantC,
70+
unless(anyOf(
71+
hasDescendant(mapAnyOf(ifStmt, whileStmt, forStmt, doStmt)
72+
.with(HasWaitDescendantC)),
73+
hasParent(mapAnyOf(whileStmt, forStmt, doStmt)),
74+
hasParent(compoundStmt(
75+
hasParent(mapAnyOf(whileStmt, forStmt, doStmt))))))),
9076
this);
9177
}
9278
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
113113
// Detect suspicious calls to string compare:
114114
// 'if (strcmp())' -> 'if (strcmp() != 0)'
115115
Finder->addMatcher(
116-
stmt(anyOf(ifStmt(hasCondition(StringCompareCallExpr)),
117-
whileStmt(hasCondition(StringCompareCallExpr)),
118-
doStmt(hasCondition(StringCompareCallExpr)),
119-
forStmt(hasCondition(StringCompareCallExpr)),
116+
stmt(anyOf(mapAnyOf(ifStmt, whileStmt, doStmt, forStmt)
117+
.with(hasCondition(StringCompareCallExpr)),
120118
binaryOperator(hasAnyOperatorName("&&", "||"),
121119
hasEitherOperand(StringCompareCallExpr))))
122120
.bind("missing-comparison"),

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ void UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
4040

4141
// Self-check: Code compares something with 'this' pointer. We don't check
4242
// whether it is actually the parameter what we compare.
43-
const auto HasNoSelfCheck = cxxMethodDecl(unless(anyOf(
44-
hasDescendant(binaryOperator(hasAnyOperatorName("==", "!="),
45-
has(ignoringParenCasts(cxxThisExpr())))),
46-
hasDescendant(cxxOperatorCallExpr(
47-
hasAnyOverloadedOperatorName("==", "!="), argumentCountIs(2),
48-
has(ignoringParenCasts(cxxThisExpr())))))));
43+
const auto HasNoSelfCheck = cxxMethodDecl(unless(hasDescendant(
44+
binaryOperation(hasAnyOperatorName("==", "!="),
45+
hasEitherOperand(ignoringParenCasts(cxxThisExpr()))))));
4946

5047
// Both copy-and-swap and copy-and-move method creates a copy first and
5148
// assign it to 'this' with swap or move.

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,7 @@ void UseAfterMoveFinder::getReinits(
310310
// Assignment. In addition to the overloaded assignment operator,
311311
// test for built-in assignment as well, since template functions
312312
// may be instantiated to use std::move() on built-in types.
313-
binaryOperator(hasOperatorName("="), hasLHS(DeclRefMatcher)),
314-
cxxOperatorCallExpr(hasOverloadedOperatorName("="),
315-
hasArgument(0, DeclRefMatcher)),
313+
binaryOperation(hasOperatorName("="), hasLHS(DeclRefMatcher)),
316314
// Declaration. We treat this as a type of reinitialization too,
317315
// so we don't need to treat it separately.
318316
declStmt(hasDescendant(equalsNode(MovedVariable))),

clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,16 @@ void MutatingCopyCheck::registerMatchers(MatchFinder *Finder) {
3030
MemberExprOrSourceObject);
3131

3232
const auto IsSourceMutatingAssignment = traverse(
33-
TK_AsIs,
34-
expr(anyOf(binaryOperator(isAssignmentOperator(), hasLHS(IsPartOfSource))
35-
.bind(MutatingOperatorName),
36-
cxxOperatorCallExpr(isAssignmentOperator(),
37-
hasArgument(0, IsPartOfSource))
38-
.bind(MutatingOperatorName))));
33+
TK_AsIs, binaryOperation(hasOperatorName("="), hasLHS(IsPartOfSource))
34+
.bind(MutatingOperatorName));
3935

4036
const auto MemberExprOrSelf = anyOf(memberExpr(), cxxThisExpr());
4137

4238
const auto IsPartOfSelf = allOf(
4339
unless(hasDescendant(expr(unless(MemberExprOrSelf)))), MemberExprOrSelf);
4440

4541
const auto IsSelfMutatingAssignment =
46-
expr(anyOf(binaryOperator(isAssignmentOperator(), hasLHS(IsPartOfSelf)),
47-
cxxOperatorCallExpr(isAssignmentOperator(),
48-
hasArgument(0, IsPartOfSelf))));
42+
binaryOperation(isAssignmentOperator(), hasLHS(IsPartOfSelf));
4943

5044
const auto IsSelfMutatingMemberFunction =
5145
functionDecl(hasBody(hasDescendant(IsSelfMutatingAssignment)));

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ void AvoidGotoCheck::registerMatchers(MatchFinder *Finder) {
2929

3030
// Check if the 'goto' is used for control flow other than jumping
3131
// out of a nested loop.
32-
auto Loop = stmt(anyOf(forStmt(), cxxForRangeStmt(), whileStmt(), doStmt()));
33-
auto NestedLoop =
34-
stmt(anyOf(forStmt(hasAncestor(Loop)), cxxForRangeStmt(hasAncestor(Loop)),
35-
whileStmt(hasAncestor(Loop)), doStmt(hasAncestor(Loop))));
32+
auto Loop = mapAnyOf(forStmt, cxxForRangeStmt, whileStmt, doStmt);
33+
auto NestedLoop = Loop.with(hasAncestor(Loop));
3634

3735
Finder->addMatcher(gotoStmt(anyOf(unless(hasAncestor(NestedLoop)),
3836
unless(isForwardJumping())))

clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ void PreferIsaOrDynCastInConditionalsCheck::registerMatchers(
4747
allOf(callee(namedDecl(hasAnyName("isa", "cast", "cast_or_null",
4848
"dyn_cast", "dyn_cast_or_null"))
4949
.bind("func")),
50-
hasArgument(0, anyOf(declRefExpr().bind("arg"),
51-
cxxMemberCallExpr().bind("arg"))))))
50+
hasArgument(
51+
0,
52+
mapAnyOf(declRefExpr, cxxMemberCallExpr).bind("arg")))))
5253
.bind("rhs");
5354

5455
Finder->addMatcher(

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

+3-13
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,6 @@ StatementMatcher makeIteratorLoopMatcher(bool IsReverse) {
188188
StatementMatcher IteratorComparisonMatcher = expr(
189189
ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName)))));
190190

191-
auto OverloadedNEQMatcher = ignoringImplicit(
192-
cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
193-
hasArgument(0, IteratorComparisonMatcher),
194-
hasArgument(1, IteratorBoundMatcher)));
195-
196191
// This matcher tests that a declaration is a CXXRecordDecl that has an
197192
// overloaded operator*(). If the operator*() returns by value instead of by
198193
// reference then the return type is tagged with DerefByValueResultName.
@@ -216,14 +211,9 @@ StatementMatcher makeIteratorLoopMatcher(bool IsReverse) {
216211
containsDeclaration(0, InitDeclMatcher),
217212
containsDeclaration(1, EndDeclMatcher)),
218213
declStmt(hasSingleDecl(InitDeclMatcher)))),
219-
hasCondition(
220-
anyOf(binaryOperator(hasOperatorName("!="),
221-
hasLHS(IteratorComparisonMatcher),
222-
hasRHS(IteratorBoundMatcher)),
223-
binaryOperator(hasOperatorName("!="),
224-
hasLHS(IteratorBoundMatcher),
225-
hasRHS(IteratorComparisonMatcher)),
226-
OverloadedNEQMatcher)),
214+
hasCondition(ignoringImplicit(binaryOperation(
215+
hasOperatorName("!="), hasOperands(IteratorComparisonMatcher,
216+
IteratorBoundMatcher)))),
227217
hasIncrement(anyOf(
228218
unaryOperator(hasOperatorName("++"),
229219
hasUnaryOperand(declRefExpr(

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

+4-9
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,10 @@ static bool isCopyAssignmentAndCanBeDefaulted(ASTContext *Context,
183183
auto LHS = memberExpr(hasObjectExpression(cxxThisExpr()),
184184
member(fieldDecl(equalsNode(Field))));
185185
auto RHS = accessToFieldInVar(Field, Param);
186-
if (match(
187-
traverse(TK_AsIs,
188-
compoundStmt(has(ignoringParenImpCasts(stmt(anyOf(
189-
binaryOperator(hasOperatorName("="), hasLHS(LHS),
190-
hasRHS(RHS)),
191-
cxxOperatorCallExpr(
192-
hasOverloadedOperatorName("="), argumentCountIs(2),
193-
hasArgument(0, LHS), hasArgument(1, RHS)))))))),
194-
*Compound, *Context)
186+
if (match(traverse(TK_AsIs,
187+
compoundStmt(has(ignoringParenImpCasts(binaryOperation(
188+
hasOperatorName("="), hasLHS(LHS), hasRHS(RHS)))))),
189+
*Compound, *Context)
195190
.empty())
196191
return false;
197192
}

clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ void MoveConstArgCheck::registerMatchers(MatchFinder *Finder) {
4747

4848
Finder->addMatcher(MoveCallMatcher, this);
4949

50-
auto ConstParamMatcher = forEachArgumentWithParam(
51-
MoveCallMatcher, parmVarDecl(hasType(references(isConstQualified()))));
52-
53-
Finder->addMatcher(callExpr(ConstParamMatcher).bind("receiving-expr"), this);
5450
Finder->addMatcher(
55-
traverse(TK_AsIs,
56-
cxxConstructExpr(ConstParamMatcher).bind("receiving-expr")),
51+
invocation(forEachArgumentWithParam(
52+
MoveCallMatcher,
53+
parmVarDecl(hasType(references(isConstQualified())))))
54+
.bind("receiving-expr"),
5755
this);
5856
}
5957

clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp

+25-26
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,23 @@ AST_MATCHER(Expr, usedInBooleanContext) {
5656
const char *ExprName = "__booleanContextExpr";
5757
auto Result =
5858
expr(expr().bind(ExprName),
59-
anyOf(hasParent(varDecl(hasType(booleanType()))),
59+
anyOf(hasParent(
60+
mapAnyOf(varDecl, fieldDecl).with(hasType(booleanType()))),
6061
hasParent(cxxConstructorDecl(
6162
hasAnyConstructorInitializer(cxxCtorInitializer(
6263
withInitializer(expr(equalsBoundNode(ExprName))),
6364
forField(hasType(booleanType())))))),
64-
hasParent(fieldDecl(hasType(booleanType()))),
6565
hasParent(stmt(anyOf(
6666
explicitCastExpr(hasDestinationType(booleanType())),
67-
ifStmt(hasCondition(expr(equalsBoundNode(ExprName)))),
68-
doStmt(hasCondition(expr(equalsBoundNode(ExprName)))),
69-
whileStmt(hasCondition(expr(equalsBoundNode(ExprName)))),
70-
forStmt(hasCondition(expr(equalsBoundNode(ExprName)))),
71-
conditionalOperator(
72-
hasCondition(expr(equalsBoundNode(ExprName)))),
67+
mapAnyOf(ifStmt, doStmt, whileStmt, forStmt,
68+
conditionalOperator)
69+
.with(hasCondition(expr(equalsBoundNode(ExprName)))),
7370
parenListExpr(hasParent(varDecl(hasType(booleanType())))),
7471
parenExpr(hasParent(
7572
explicitCastExpr(hasDestinationType(booleanType())))),
7673
returnStmt(forFunction(returns(booleanType()))),
7774
cxxUnresolvedConstructExpr(hasType(booleanType())),
78-
callExpr(hasAnyArgumentWithParam(
75+
invocation(hasAnyArgumentWithParam(
7976
expr(equalsBoundNode(ExprName)),
8077
parmVarDecl(hasType(booleanType())))),
8178
binaryOperator(hasAnyOperatorName("&&", "||")),
@@ -181,21 +178,12 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
181178
expr(hasType(pointsTo(ValidContainer))).bind("Pointee"))),
182179
expr(hasType(ValidContainer)).bind("STLObject"));
183180
Finder->addMatcher(
184-
cxxOperatorCallExpr(
185-
unless(isInTemplateInstantiation()),
186-
hasAnyOverloadedOperatorName("==", "!="),
187-
anyOf(allOf(hasArgument(0, WrongComparend), hasArgument(1, STLArg)),
188-
allOf(hasArgument(0, STLArg), hasArgument(1, WrongComparend))),
189-
unless(hasAncestor(
190-
cxxMethodDecl(ofClass(equalsBoundNode("container"))))))
191-
.bind("BinCmp"),
192-
this);
193-
Finder->addMatcher(
194-
binaryOperator(hasAnyOperatorName("==", "!="),
195-
anyOf(allOf(hasLHS(WrongComparend), hasRHS(STLArg)),
196-
allOf(hasLHS(STLArg), hasRHS(WrongComparend))),
197-
unless(hasAncestor(
198-
cxxMethodDecl(ofClass(equalsBoundNode("container"))))))
181+
binaryOperation(unless(isInTemplateInstantiation()),
182+
hasAnyOperatorName("==", "!="),
183+
hasOperands(ignoringParenImpCasts(WrongComparend),
184+
ignoringParenImpCasts(STLArg)),
185+
unless(hasAncestor(cxxMethodDecl(
186+
ofClass(equalsBoundNode("container"))))))
199187
.bind("BinCmp"),
200188
this);
201189
}
@@ -206,6 +194,8 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
206194
Result.Nodes.getNodeAs<Expr>("MemberCallObject");
207195
const auto *BinCmp = Result.Nodes.getNodeAs<CXXOperatorCallExpr>("BinCmp");
208196
const auto *BinCmpTempl = Result.Nodes.getNodeAs<BinaryOperator>("BinCmp");
197+
const auto *BinCmpRewritten =
198+
Result.Nodes.getNodeAs<CXXRewrittenBinaryOperator>("BinCmp");
209199
const auto *BinaryOp = Result.Nodes.getNodeAs<BinaryOperator>("SizeBinaryOp");
210200
const auto *Pointee = Result.Nodes.getNodeAs<Expr>("Pointee");
211201
const auto *E =
@@ -236,6 +226,12 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
236226
}
237227
Hint = FixItHint::CreateReplacement(BinCmpTempl->getSourceRange(),
238228
ReplacementText);
229+
} else if (BinCmpRewritten) {
230+
if (BinCmpRewritten->getOpcode() == BinaryOperatorKind::BO_NE) {
231+
ReplacementText = "!" + ReplacementText;
232+
}
233+
Hint = FixItHint::CreateReplacement(BinCmpRewritten->getSourceRange(),
234+
ReplacementText);
239235
} else if (BinaryOp) { // Determine the correct transformation.
240236
bool Negation = false;
241237
const bool ContainerIsLHS =
@@ -313,8 +309,11 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
313309
"for emptiness instead of 'size'")
314310
<< Hint;
315311
} else {
316-
WarnLoc = BinCmpTempl ? BinCmpTempl->getBeginLoc()
317-
: (BinCmp ? BinCmp->getBeginLoc() : SourceLocation{});
312+
WarnLoc = BinCmpTempl
313+
? BinCmpTempl->getBeginLoc()
314+
: (BinCmp ? BinCmp->getBeginLoc()
315+
: (BinCmpRewritten ? BinCmpRewritten->getBeginLoc()
316+
: SourceLocation{}));
318317
diag(WarnLoc, "the 'empty' method should be used to check "
319318
"for emptiness instead of comparing to an empty object")
320319
<< Hint;

clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ void RedundantControlFlowCheck::registerMatchers(MatchFinder *Finder) {
3737
has(compoundStmt(hasAnySubstatement(returnStmt(unless(has(expr())))))
3838
.bind("return"))),
3939
this);
40-
auto CompoundContinue =
41-
has(compoundStmt(hasAnySubstatement(continueStmt())).bind("continue"));
4240
Finder->addMatcher(
43-
stmt(anyOf(forStmt(), cxxForRangeStmt(), whileStmt(), doStmt()),
44-
CompoundContinue),
41+
mapAnyOf(forStmt, cxxForRangeStmt, whileStmt, doStmt)
42+
.with(hasBody(compoundStmt(hasAnySubstatement(continueStmt()))
43+
.bind("continue"))),
4544
this);
4645
}
4746

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
6666
substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue))));
6767
auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
6868
DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
69-
Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
70-
extractNodesByIdTo(Matches, "declRef", DeclRefs);
71-
Matches =
72-
match(findAll(cxxConstructExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
69+
Matches = match(findAll(invocation(UsedAsConstRefOrValueArg)), Stmt, Context);
7370
extractNodesByIdTo(Matches, "declRef", DeclRefs);
7471
// References and pointers to const assignments.
7572
Matches =

0 commit comments

Comments
 (0)