|
38 | 38 | } |
39 | 39 | //----------------------------------------------------------------------------- |
40 | 40 |
|
| 41 | +namespace ranges = std::ranges; |
| 42 | +//----------------------------------------------------------------------------- |
41 | 43 | namespace clang::insights { |
42 | 44 |
|
43 | 45 | #define BUILD_OPT_AND(name, param) std::function name = [](param t) -> MyOptional<param> |
@@ -1524,11 +1526,8 @@ void CodeGenerator::InsertMethodBody(const FunctionDecl* stmt, const size_t posB |
1524 | 1526 |
|
1525 | 1527 | // handle C++ [basic.start.main] §5: main can have no return statement |
1526 | 1528 | if(stmt->hasImplicitReturnZero()) { |
1527 | | - // TODO replace with ranges::find_if |
1528 | | - const auto cmpBody = dyn_cast<CompoundStmt>(stmt->getBody())->body(); |
1529 | | - mRequiresImplicitReturnZero = |
1530 | | - std::end(cmpBody) == |
1531 | | - std::find_if(cmpBody.begin(), cmpBody.end(), [](const Stmt* e) { return isa<ReturnStmt>(e); }); |
| 1529 | + mRequiresImplicitReturnZero = ranges::none_of(dyn_cast<CompoundStmt>(stmt->getBody())->body(), |
| 1530 | + [](const Stmt* e) { return isa<ReturnStmt>(e); }); |
1532 | 1531 | } |
1533 | 1532 |
|
1534 | 1533 | const auto* body = stmt->getBody(); |
@@ -1754,11 +1753,10 @@ void CodeGenerator::InsertArg(const ClassTemplateDecl* stmt) |
1754 | 1753 | } |
1755 | 1754 |
|
1756 | 1755 | // Sort specializations by POI to make dependent specializations work. |
1757 | | - std::sort(specializations.begin(), |
1758 | | - specializations.end(), |
1759 | | - [](const ClassTemplateSpecializationDecl* a, const ClassTemplateSpecializationDecl* b) { |
1760 | | - return a->getPointOfInstantiation() < b->getPointOfInstantiation(); |
1761 | | - }); |
| 1756 | + ranges::sort(specializations, |
| 1757 | + [](const ClassTemplateSpecializationDecl* a, const ClassTemplateSpecializationDecl* b) { |
| 1758 | + return a->getPointOfInstantiation() < b->getPointOfInstantiation(); |
| 1759 | + }); |
1762 | 1760 |
|
1763 | 1761 | for(const auto* spec : specializations) { |
1764 | 1762 | InsertArg(spec); |
@@ -4621,17 +4619,8 @@ void CodeGenerator::HandleLambdaExpr(const LambdaExpr* lambda, LambdaHelper& lam |
4621 | 4619 |
|
4622 | 4620 | outputFormatHelper.AppendNewLine(); |
4623 | 4621 | LambdaCodeGenerator codeGenerator{outputFormatHelper, mLambdaStack, mProcessingPrimaryTemplate}; |
4624 | | - codeGenerator.mCapturedThisAsCopy = [&] { |
4625 | | - for(const auto& c : lambda->captures()) { |
4626 | | - const auto captureKind = c.getCaptureKind(); |
4627 | | - |
4628 | | - if(c.capturesThis() and (captureKind == LCK_StarThis)) { |
4629 | | - return true; |
4630 | | - } |
4631 | | - } |
4632 | | - |
4633 | | - return false; |
4634 | | - }(); |
| 4622 | + codeGenerator.mCapturedThisAsCopy = ranges::any_of( |
| 4623 | + lambda->captures(), [](auto& c) { return (c.capturesThis() and (c.getCaptureKind() == LCK_StarThis)); }); |
4635 | 4624 |
|
4636 | 4625 | codeGenerator.mLambdaExpr = lambda; |
4637 | 4626 | codeGenerator.InsertArg(lambda->getLambdaClass()); |
|
0 commit comments