From 9d152f6bb6009d9d66ee3565b57117320986343b Mon Sep 17 00:00:00 2001 From: "petro.zarytskyi" Date: Sun, 14 Jan 2024 23:23:01 +0200 Subject: [PATCH] Apply suggestions of clang-tidy. --- .../MultiplexExternalRMVSource.cpp | 2 +- lib/Differentiator/ReverseModeVisitor.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Differentiator/MultiplexExternalRMVSource.cpp b/lib/Differentiator/MultiplexExternalRMVSource.cpp index 53166af0e..b2717fccb 100644 --- a/lib/Differentiator/MultiplexExternalRMVSource.cpp +++ b/lib/Differentiator/MultiplexExternalRMVSource.cpp @@ -122,7 +122,7 @@ void MultiplexExternalRMVSource:: void MultiplexExternalRMVSource:: ActBeforeDifferentiatingLoopCondition() { - for (auto source : m_Sources) { + for (auto* source : m_Sources) { source->ActBeforeDifferentiatingLoopCondition(); } } diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index c1c84e845..969d15c37 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -788,7 +788,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, /// FIXME: Explain this. if ((isa(S) || isa(S) || isa(S)) && isa(SDiff.getStmt_dx())) { - auto returnCS = cast(SDiff.getStmt_dx()); + auto* returnCS = cast(SDiff.getStmt_dx()); for (auto iter = returnCS->body_rbegin(), E = returnCS->body_rend(); iter!=E; iter++) addToCurrentBlock(*iter, direction::reverse); } else { @@ -1064,10 +1064,10 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, const Stmt* init = FS->getInit(); if (m_ExternalSource) m_ExternalSource->ActBeforeDifferentiatingLoopInitStmt(); - StmtDiff initResult = nullptr; + StmtDiff initResult; if (init) { initResult = DifferentiateSingleStmt(init); - if (auto initDeclStmt = dyn_cast(initResult.getStmt())) { + if (auto* initDeclStmt = dyn_cast(initResult.getStmt())) { auto* VD = cast(initDeclStmt->getSingleDecl()); Expr* initValue = VD->getInit(); initResult.updateStmt(BuildOp(BO_Assign, BuildDeclRef(VD), initValue)); @@ -2459,7 +2459,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, direction::reverse); for (auto& S : RBlock) addToCurrentBlock(S, direction::reverse); - Ldiff = LCloned; + Ldiff = LCloned; } else if (opCode == BO_DivAssign) { auto RDelayed = DelayedGlobalStoreAndRef(R, /*prefix=*/"_t", /*forceNoRecompute=*/true); StmtDiff& RResult = RDelayed.Result; @@ -3037,9 +3037,9 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, class PlaceholderReplacer : public RecursiveASTVisitor { public: const Expr* placeholder; - Expr* newExpr; + Expr* newExpr{nullptr}; PlaceholderReplacer(const Expr* Placeholder) - : placeholder(Placeholder), newExpr(nullptr) {} + : placeholder(Placeholder) {} bool VisitExpr(Expr *E) { for (auto iter = E->child_begin(), e = E->child_end(); @@ -3282,13 +3282,13 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, } addToCurrentBlock(condDiff.getStmt_dx(), direction::reverse); bodyDiff = Visit(body); - if (auto bodyCS = dyn_cast(bodyDiff.getStmt())) + if (auto* bodyCS = dyn_cast(bodyDiff.getStmt())) for (Stmt* S : bodyCS->body()) addToCurrentBlock(S, direction::forward); else addToCurrentBlock(bodyDiff.getStmt(), direction::forward); if (bodyDiff.getStmt_dx()) { - if (auto bodyDxCS = dyn_cast(bodyDiff.getStmt_dx())) + if (auto* bodyDxCS = dyn_cast(bodyDiff.getStmt_dx())) for (auto iter = bodyDxCS->body_rbegin(), e = bodyDxCS->body_rend(); iter != e; ++iter) addToCurrentBlock(*iter, direction::reverse); @@ -3316,7 +3316,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, bodyDiff = DifferentiateSingleStmt(body, /*dfdS=*/nullptr); addToCurrentBlock(bodyDiff.getStmt(), direction::forward); if (bodyDiff.getStmt_dx()) { - if (auto bodyDxCS = dyn_cast(bodyDiff.getStmt_dx())) + if (auto* bodyDxCS = dyn_cast(bodyDiff.getStmt_dx())) for (auto iter = bodyDxCS->body_rbegin(), e = bodyDxCS->body_rend(); iter != e; ++iter) addToCurrentBlock(*iter, direction::reverse);