diff --git a/lib/Differentiator/ActivityAnalyzer.cpp b/lib/Differentiator/ActivityAnalyzer.cpp index 0b7e34699..9321b76c3 100644 --- a/lib/Differentiator/ActivityAnalyzer.cpp +++ b/lib/Differentiator/ActivityAnalyzer.cpp @@ -65,12 +65,13 @@ void VariedAnalyzer::AnalyzeCFGBlock(const CFGBlock& block) { merge(succData.get(), m_BlockData[block.getBlockID()].get()); } - // FIXME: Information about the varied variables is stored in the last block, so we should be able to get it form there + // FIXME: Information about the varied variables is stored in the last block, + // so we should be able to get it form there for (const VarDecl* i : *m_BlockData[block.getBlockID()]) m_VariedDecls.insert(i); } -bool VariedAnalyzer::isVaried(const VarDecl* VD) const{ +bool VariedAnalyzer::isVaried(const VarDecl* VD) const { const VarsData& curBranch = getCurBlockVarsData(); return curBranch.find(VD) != curBranch.end(); } @@ -113,21 +114,21 @@ bool VariedAnalyzer::VisitConditionalOperator(ConditionalOperator* CO) { } bool VariedAnalyzer::VisitCallExpr(CallExpr* CE) { - FunctionDecl* FD = CE->getDirectCallee(); + FunctionDecl* FD = CE->getDirectCallee(); bool noHiddenParam = (CE->getNumArgs() == FD->getNumParams()); std::set variedParam; - if(noHiddenParam){ - MutableArrayRef FDparam = FD->parameters(); - for (std::size_t i = 0, e = CE->getNumArgs(); i != e; ++i){ + if (noHiddenParam) { + MutableArrayRef FDparam = FD->parameters(); + for (std::size_t i = 0, e = CE->getNumArgs(); i != e; ++i) { clang::Expr* par = CE->getArg(i); TraverseStmt(par); - if(m_Varied){ + if (m_Varied) { m_VariedDecls.insert(FDparam[i]); m_Varied = false; } } } - return true; + return true; } bool VariedAnalyzer::VisitDeclStmt(DeclStmt* DS) { @@ -163,4 +164,3 @@ bool VariedAnalyzer::VisitDeclRefExpr(DeclRefExpr* DRE) { return true; } } // namespace clad - diff --git a/lib/Differentiator/ActivityAnalyzer.h b/lib/Differentiator/ActivityAnalyzer.h index d42d61c6f..bb0eca6d0 100644 --- a/lib/Differentiator/ActivityAnalyzer.h +++ b/lib/Differentiator/ActivityAnalyzer.h @@ -8,16 +8,15 @@ #include "clad/Differentiator/Compatibility.h" #include -#include #include #include #include #include #include /// @brief Class that implemets Varied part of the Activity analysis. -/// By performing static data-flow analysis, so called Varied variables -/// are determined, meaning variables that depend on input parameters -/// in a differentiable way. That result enables us to remove redundant +/// By performing static data-flow analysis, so called Varied variables +/// are determined, meaning variables that depend on input parameters +/// in a differentiable way. That result enables us to remove redundant /// statements in the reverse mode, improving generated codes efficiency. namespace clad { class VariedAnalyzer : public clang::RecursiveASTVisitor { @@ -45,12 +44,15 @@ class VariedAnalyzer : public clang::RecursiveASTVisitor { bool isVaried(const clang::VarDecl* VD) const; void copyVarToCurBlock(const clang::VarDecl* VD); VarsData& getCurBlockVarsData() { return *m_BlockData[m_CurBlockID]; } - const VarsData& getCurBlockVarsData() const { return const_cast(this)->getCurBlockVarsData();} + const VarsData& getCurBlockVarsData() const { + return const_cast(this)->getCurBlockVarsData(); + } void AnalyzeCFGBlock(const clang::CFGBlock& block); public: /// Constructor - VariedAnalyzer(clang::ASTContext& Context, std::set& Decls) + VariedAnalyzer(clang::ASTContext& Context, + std::set& Decls) : m_VariedDecls(Decls), m_Context(Context) {} /// Destructor