Skip to content

Commit c48920c

Browse files
committed
major fixes
1 parent bb85bac commit c48920c

13 files changed

+35
-38
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@ 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-
}
47+
if (llvm::any_of(Node.ctors(), [](const CXXConstructorDecl *C) {
48+
return C->isCopyOrMoveConstructor() && C->isDefaulted() &&
49+
!C->isDeleted();
50+
}))
51+
return false;
5152
if (llvm::any_of(Node.methods(), [](const CXXMethodDecl *M) {
52-
if (M->isCopyAssignmentOperator())
53-
llvm::errs() << M->isDeleted() << "\n";
54-
return (M->isCopyAssignmentOperator() && M->isDefaulted() &&
55-
!M->isDeleted()) ||
56-
(M->isMoveAssignmentOperator() && M->isDefaulted() &&
57-
!M->isDeleted());
53+
return (M->isCopyAssignmentOperator() ||
54+
M->isMoveAssignmentOperator()) &&
55+
M->isDefaulted() && !M->isDeleted();
5856
}))
5957
return false;
6058
// FIXME: find ways to identifier correct handle capture this lambda

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ static bool lazyMapOfSetsIntersectionExists(const MapTy &Map, const ElemTy &E1,
15891589
if (E1Iterator == Map.end() || E2Iterator == Map.end())
15901590
return false;
15911591

1592-
return llvm::any_of(E1Iterator->second, [&](const auto &E1SetElem) {
1592+
return llvm::any_of(E1Iterator->second, [&E2Iterator](const auto &E1SetElem) {
15931593
return E2Iterator->second.contains(E1SetElem);
15941594
});
15951595
}

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-
const DeclStmt *Stmts[] = {Node.getBeginStmt(), Node.getEndStmt()};
23-
return llvm::any_of(Stmts, [&](const DeclStmt *Stmt) {
24-
return Stmt != nullptr && InnerMatcher.matches(*Stmt, Finder, Builder);
25-
});
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/misc/NewDeleteOverloadsCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ hasCorrespondingOverloadInBaseClass(const CXXMethodDecl *MD,
114114
RD = MD->getParent();
115115
}
116116

117-
return llvm::any_of(RD->bases(), [&](const auto &BS) {
117+
return llvm::any_of(RD->bases(), [&](const CXXBaseSpecifier &BS) {
118118
// We can't say much about a dependent base class, but to avoid false
119119
// positives assume it can have a corresponding overload.
120120
if (BS.getType()->isDependentType())
121121
return true;
122-
if (const auto *BaseRD = BS.getType()->getAsCXXRecordDecl())
122+
if (const CXXRecordDecl *BaseRD = BS.getType()->getAsCXXRecordDecl())
123123
return hasCorrespondingOverloadInBaseClass(MD, BaseRD);
124124
return false;
125125
});

clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static bool isOverrideMethod(const FunctionDecl *Function) {
3030

3131
static bool hasAttrAfterParam(const SourceManager *SourceManager,
3232
const ParmVarDecl *Param) {
33-
return llvm::any_of(Param->attrs(), [&](const auto *Attr) {
33+
return llvm::any_of(Param->attrs(), [&](const Attr *Attr) {
3434
return SourceManager->isBeforeInTranslationUnit(Param->getLocation(),
3535
Attr->getLocation());
3636
});

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,22 +511,22 @@ static bool canBeModified(ASTContext *Context, const Expr *E) {
511511
/// Returns true when it can be guaranteed that the elements of the
512512
/// container are not being modified.
513513
static bool usagesAreConst(ASTContext *Context, const UsageResult &Usages) {
514-
return llvm::all_of(Usages, [&](const Usage &U) {
514+
return llvm::none_of(Usages, [&Context](const Usage &U) {
515515
// Lambda captures are just redeclarations (VarDecl) of the same variable,
516516
// not expressions. If we want to know if a variable that is captured by
517517
// reference can be modified in an usage inside the lambda's body, we need
518518
// to find the expression corresponding to that particular usage, later in
519519
// this loop.
520-
return U.Kind == Usage::UK_CaptureByCopy ||
521-
U.Kind == Usage::UK_CaptureByRef ||
522-
!canBeModified(Context, U.Expression);
520+
return U.Kind != Usage::UK_CaptureByCopy &&
521+
U.Kind != Usage::UK_CaptureByRef &&
522+
canBeModified(Context, U.Expression);
523523
});
524524
}
525525

526526
/// Returns true if the elements of the container are never accessed
527527
/// by reference.
528528
static bool usagesReturnRValues(const UsageResult &Usages) {
529-
return llvm::all_of(Usages, [](const auto &U) {
529+
return llvm::all_of(Usages, [](const Usage &U) {
530530
return !U.Expression || U.Expression->isPRValue();
531531
});
532532
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ bool DependencyFinderASTVisitor::VisitVarDecl(VarDecl *V) {
8989

9090
// Next, check if the variable was removed from existence by an earlier
9191
// iteration.
92-
if (llvm::all_of(*ReplacedVars, [&](const auto &I) { return I.second != V; }))
92+
if (llvm::none_of(*ReplacedVars,
93+
[&](const auto &I) { return I.second == V; }))
9394
return true;
9495
DependsOnInsideVariable = true;
9596
return false;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ AST_MATCHER_P(NamedDecl, hasAnyNameIgnoringTemplates, std::vector<StringRef>,
4545
// FullNameTrimmed matches any of the given Names.
4646
const StringRef FullNameTrimmedRef = FullNameTrimmed;
4747
return llvm::any_of(Names, [&](const StringRef Pattern) {
48-
if (Pattern.starts_with("::")) {
48+
if (Pattern.starts_with("::"))
4949
return FullNameTrimmed == Pattern;
50-
}
5150
return FullNameTrimmedRef.ends_with(Pattern) &&
5251
FullNameTrimmedRef.drop_back(Pattern.size()).ends_with("::");
5352
});

clang-tools-extra/clang-tidy/objc/MissingHashCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ AST_MATCHER_P(ObjCImplementationDecl, hasInterface,
2525
AST_MATCHER_P(ObjCContainerDecl, hasInstanceMethod,
2626
ast_matchers::internal::Matcher<ObjCMethodDecl>, Base) {
2727
// Check each instance method against the provided matcher.
28-
return llvm::any_of(Node.instance_methods(), [&](const auto *I) {
28+
return llvm::any_of(Node.instance_methods(), [&](const ObjCMethodDecl *I) {
2929
return Base.matches(*I, Finder, Builder);
3030
});
3131
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ namespace clang::tidy::readability {
2020
namespace {
2121

2222
AST_MATCHER(CXXMethodDecl, hasOnlyDefaultParameters) {
23-
return llvm::all_of(Node.parameters(),
24-
[](const auto *Param) { return Param->hasDefaultArg(); });
23+
return llvm::all_of(Node.parameters(), [](const ParmVarDecl *Param) {
24+
return Param->hasDefaultArg();
25+
});
2526
}
2627

2728
const auto DefaultSmartPointers = "::std::shared_ptr;::std::unique_ptr;"

0 commit comments

Comments
 (0)