Skip to content

Commit 5b3c422

Browse files
authored
merge main into amd-staging (#742)
2 parents 669729e + 38c7495 commit 5b3c422

File tree

164 files changed

+6505
-5106
lines changed

Some content is hidden

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

164 files changed

+6505
-5106
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ Checks: >
3232
-readability-qualified-auto,
3333
-readability-simplify-boolean-expr,
3434
-readability-static-definition-in-anonymous-namespace,
35-
-readability-suspicious-call-argument,
36-
-readability-use-anyofallof
35+
-readability-suspicious-call-argument
3736
3837
CheckOptions:
3938
- key: performance-move-const-arg.CheckTriviallyCopyableMove

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,10 @@ bool ClangTidyDiagnosticConsumer::passesLineFilter(StringRef FileName,
478478
if (FileName.ends_with(Filter.Name)) {
479479
if (Filter.LineRanges.empty())
480480
return true;
481-
for (const FileFilter::LineRange &Range : Filter.LineRanges) {
482-
if (Range.first <= LineNumber && LineNumber <= Range.second)
483-
return true;
484-
}
485-
return false;
481+
return llvm::any_of(
482+
Filter.LineRanges, [&](const FileFilter::LineRange &Range) {
483+
return Range.first <= LineNumber && LineNumber <= Range.second;
484+
});
486485
}
487486
}
488487
return false;

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,9 @@ static bool isFallthroughSwitchBranch(const SwitchBranch &Branch) {
7575
if (!S)
7676
return true;
7777

78-
for (const Attr *A : S->getAttrs()) {
79-
if (isa<FallThroughAttr>(A))
80-
return false;
81-
}
82-
83-
return true;
78+
return llvm::all_of(S->getAttrs(), [](const Attr *A) {
79+
return !isa<FallThroughAttr>(A);
80+
});
8481
}
8582
} Visitor;
8683

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,17 @@ AST_MATCHER(CXXRecordDecl, correctHandleCaptureThisLambda) {
4444
if (Node.hasSimpleMoveAssignment())
4545
return false;
4646

47-
for (const CXXConstructorDecl *C : Node.ctors()) {
48-
if (C->isCopyOrMoveConstructor() && C->isDefaulted() && !C->isDeleted())
49-
return false;
50-
}
51-
for (const CXXMethodDecl *M : Node.methods()) {
52-
if (M->isCopyAssignmentOperator())
53-
llvm::errs() << M->isDeleted() << "\n";
54-
if (M->isCopyAssignmentOperator() && M->isDefaulted() && !M->isDeleted())
55-
return false;
56-
if (M->isMoveAssignmentOperator() && M->isDefaulted() && !M->isDeleted())
57-
return false;
58-
}
47+
if (llvm::any_of(Node.ctors(), [](const CXXConstructorDecl *C) {
48+
return C->isCopyOrMoveConstructor() && C->isDefaulted() &&
49+
!C->isDeleted();
50+
}))
51+
return false;
52+
if (llvm::any_of(Node.methods(), [](const CXXMethodDecl *M) {
53+
return (M->isCopyAssignmentOperator() ||
54+
M->isMoveAssignmentOperator()) &&
55+
M->isDefaulted() && !M->isDeleted();
56+
}))
57+
return false;
5958
// FIXME: find ways to identifier correct handle capture this lambda
6059
return true;
6160
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,11 +1589,9 @@ static bool lazyMapOfSetsIntersectionExists(const MapTy &Map, const ElemTy &E1,
15891589
if (E1Iterator == Map.end() || E2Iterator == Map.end())
15901590
return false;
15911591

1592-
for (const auto &E1SetElem : E1Iterator->second)
1593-
if (E2Iterator->second.contains(E1SetElem))
1594-
return true;
1595-
1596-
return false;
1592+
return llvm::any_of(E1Iterator->second, [&E2Iterator](const auto &E1SetElem) {
1593+
return E2Iterator->second.contains(E1SetElem);
1594+
});
15971595
}
15981596

15991597
/// Implements the heuristic that marks two parameters related if there is

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
7272

7373
void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) {
7474
auto MatchIf = [](bool Enabled, const auto &Matcher) {
75-
ast_matchers::internal::Matcher<FunctionDecl> Nothing = unless(anything());
75+
const ast_matchers::internal::Matcher<FunctionDecl> Nothing =
76+
unless(anything());
7677
return Enabled ? Matcher : Nothing;
7778
};
7879
Finder->addMatcher(

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,9 @@ static bool isAtLeastOneCondVarChanged(const Decl *Func, const Stmt *LoopStmt,
119119
if (isVarThatIsPossiblyChanged(Func, LoopStmt, Cond, Context))
120120
return true;
121121

122-
for (const Stmt *Child : Cond->children()) {
123-
if (!Child)
124-
continue;
125-
126-
if (isAtLeastOneCondVarChanged(Func, LoopStmt, Child, Context))
127-
return true;
128-
}
129-
return false;
122+
return llvm::any_of(Cond->children(), [&](const Stmt *Child) {
123+
return Child && isAtLeastOneCondVarChanged(Func, LoopStmt, Child, Context);
124+
});
130125
}
131126

132127
/// Return the variable names in `Cond`.
@@ -240,10 +235,9 @@ static bool hasStaticLocalVariable(const Stmt *Cond) {
240235
return true;
241236
}
242237

243-
for (const Stmt *Child : Cond->children())
244-
if (Child && hasStaticLocalVariable(Child))
245-
return true;
246-
return false;
238+
return llvm::any_of(Cond->children(), [](const Stmt *Child) {
239+
return Child && hasStaticLocalVariable(Child);
240+
});
247241
}
248242

249243
/// Tests if the loop condition `Cond` involves static local variables and

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ class FindAssignToVarBefore
9292
return false;
9393
}
9494
bool VisitStmt(const Stmt *S) {
95-
for (const Stmt *Child : S->children())
96-
if (Child && Visit(Child))
97-
return true;
98-
return false;
95+
return llvm::any_of(S->children(), [this](const Stmt *Child) {
96+
return Child && Visit(Child);
97+
});
9998
}
10099
};
101100

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ namespace clang::tidy::cppcoreguidelines {
1919
namespace {
2020
AST_MATCHER_P(CXXForRangeStmt, hasRangeBeginEndStmt,
2121
ast_matchers::internal::Matcher<DeclStmt>, InnerMatcher) {
22-
for (const DeclStmt *Stmt : {Node.getBeginStmt(), Node.getEndStmt()})
23-
if (Stmt != nullptr && InnerMatcher.matches(*Stmt, Finder, Builder))
24-
return true;
25-
return false;
22+
return llvm::any_of(llvm::ArrayRef{Node.getBeginStmt(), Node.getEndStmt()},
23+
[&](const DeclStmt *Stmt) {
24+
return Stmt &&
25+
InnerMatcher.matches(*Stmt, Finder, Builder);
26+
});
2627
}
2728

2829
AST_MATCHER(Stmt, isInsideOfRangeBeginEndStmt) {

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

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ void ProTypeMemberInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
361361
}
362362

363363
// FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
364-
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) {
364+
static bool isIncompleteOrZeroLengthArrayType(const ASTContext &Context,
365+
QualType T) {
365366
if (T->isIncompleteArrayType())
366367
return true;
367368

@@ -375,7 +376,7 @@ static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) {
375376
return false;
376377
}
377378

378-
static bool isEmpty(ASTContext &Context, const QualType &Type) {
379+
static bool isEmpty(const ASTContext &Context, const QualType &Type) {
379380
if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
380381
return ClassDecl->isEmpty();
381382
}
@@ -431,19 +432,13 @@ static llvm::StringLiteral getInitializer(QualType QT, bool UseAssignment) {
431432
}
432433
}
433434

434-
void ProTypeMemberInitCheck::checkMissingMemberInitializer(
435-
ASTContext &Context, const CXXRecordDecl &ClassDecl,
436-
const CXXConstructorDecl *Ctor) {
437-
const bool IsUnion = ClassDecl.isUnion();
438-
439-
if (IsUnion && ClassDecl.hasInClassInitializer())
440-
return;
441-
442-
// Gather all fields (direct and indirect) that need to be initialized.
443-
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
435+
static void
436+
computeFieldsToInit(const ASTContext &Context, const RecordDecl &Record,
437+
bool IgnoreArrays,
438+
SmallPtrSetImpl<const FieldDecl *> &FieldsToInit) {
444439
bool AnyMemberHasInitPerUnion = false;
445440
forEachFieldWithFilter(
446-
ClassDecl, ClassDecl.fields(), AnyMemberHasInitPerUnion,
441+
Record, Record.fields(), AnyMemberHasInitPerUnion,
447442
[&](const FieldDecl *F) {
448443
if (IgnoreArrays && F->getType()->isArrayType())
449444
return;
@@ -458,6 +453,19 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
458453
!AnyMemberHasInitPerUnion)
459454
FieldsToInit.insert(F);
460455
});
456+
}
457+
458+
void ProTypeMemberInitCheck::checkMissingMemberInitializer(
459+
ASTContext &Context, const CXXRecordDecl &ClassDecl,
460+
const CXXConstructorDecl *Ctor) {
461+
const bool IsUnion = ClassDecl.isUnion();
462+
463+
if (IsUnion && ClassDecl.hasInClassInitializer())
464+
return;
465+
466+
// Gather all fields (direct and indirect) that need to be initialized.
467+
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
468+
computeFieldsToInit(Context, ClassDecl, IgnoreArrays, FieldsToInit);
461469
if (FieldsToInit.empty())
462470
return;
463471

@@ -507,7 +515,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
507515
// Collect all fields but only suggest a fix for the first member of unions,
508516
// as initializing more than one union member is an error.
509517
SmallPtrSet<const FieldDecl *, 16> FieldsToFix;
510-
AnyMemberHasInitPerUnion = false;
518+
bool AnyMemberHasInitPerUnion = false;
511519
forEachFieldWithFilter(ClassDecl, ClassDecl.fields(),
512520
AnyMemberHasInitPerUnion, [&](const FieldDecl *F) {
513521
if (!FieldsToInit.contains(F))
@@ -582,6 +590,17 @@ void ProTypeMemberInitCheck::checkMissingBaseClassInitializer(
582590

583591
void ProTypeMemberInitCheck::checkUninitializedTrivialType(
584592
const ASTContext &Context, const VarDecl *Var) {
593+
// Verify that the record actually needs initialization
594+
const CXXRecordDecl *Record = Var->getType()->getAsCXXRecordDecl();
595+
if (!Record)
596+
return;
597+
598+
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
599+
computeFieldsToInit(Context, *Record, IgnoreArrays, FieldsToInit);
600+
601+
if (FieldsToInit.empty())
602+
return;
603+
585604
const DiagnosticBuilder Diag =
586605
diag(Var->getBeginLoc(), "uninitialized record type: %0") << Var;
587606

0 commit comments

Comments
 (0)