Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Andriychuk authored and Max Andriychuk committed Sep 9, 2024
1 parent 5439ee7 commit 1395838
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/clad/Differentiator/DiffPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "clad/Differentiator/DynamicGraph.h"
#include "clad/Differentiator/ParseDiffArgsTypes.h"

#include <set>
#include <iterator>
#include <set>
namespace clang {
class CallExpr;
class CompilerInstance;
Expand Down
15 changes: 7 additions & 8 deletions lib/Differentiator/ActivityAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ void VariedAnalyzer::VisitCFGBlock(const CFGBlock& block) {
continue;
auto& succData = m_BlockData[succ->getBlockID()];

if (!succData) {
if (!succData)
succData = new VarsData(*m_BlockData[block.getBlockID()]);
}
bool m_shouldPushSucc = true;
if (succ->getBlockID() > block.getBlockID()) {
if (m_LoopMem == *m_BlockData[block.getBlockID()])
Expand Down Expand Up @@ -116,21 +115,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<const clang::VarDecl*> variedParam;
if(noHiddenParam){
MutableArrayRef<ParmVarDecl *> FDparam = FD->parameters();
for (std::size_t i = 0, e = CE->getNumArgs(); i != e; ++i){
if (noHiddenParam) {
MutableArrayRef<ParmVarDecl*> 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 == true){
if (m_Varied == true) {
m_VariedDecls.insert(FDparam[i]);
m_Varied = false;
}
}
}
return true;
return true;
}

bool VariedAnalyzer::VisitDeclStmt(DeclStmt* DS) {
Expand Down
8 changes: 5 additions & 3 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
// We do not need to create result arg for arguments passed by reference
// because the derivatives of arguments passed by reference are directly
// modified by the derived callee function.
if (utils::IsReferenceOrPointerArg(arg) || !m_DiffReq.shouldHaveAdjoint(PVD)) {
if (utils::IsReferenceOrPointerArg(arg) ||
!m_DiffReq.shouldHaveAdjoint(PVD)) {
argDiff = Visit(arg);
CallArgDx.push_back(argDiff.getExpr_dx());
} else {
Expand Down Expand Up @@ -1950,7 +1951,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
// Silence diag outputs in nested derivation process.
pullbackRequest.VerboseDiags = false;
pullbackRequest.EnableTBRAnalysis = m_DiffReq.EnableTBRAnalysis;
pullbackRequest.EnableActivityAnalysis = m_DiffReq.EnableActivityAnalysis;
pullbackRequest.EnableActivityAnalysis =
m_DiffReq.EnableActivityAnalysis;
bool isaMethod = isa<CXXMethodDecl>(FD);
for (size_t i = 0, e = FD->getNumParams(); i < e; ++i)
if (MD && isLambdaCallOperator(MD)) {
Expand Down Expand Up @@ -2107,7 +2109,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
const Expr* arg = CE->getArg(i);
StmtDiff argDiff = Visit(arg);
// Has to be removed once nondifferentiable arguments are handeled
if(argDiff.getStmt_dx())
if (argDiff.getStmt_dx())
CallArgs.push_back(argDiff.getExpr_dx());
else
CallArgs.push_back(getZeroInit(arg->getType()));
Expand Down

0 comments on commit 1395838

Please sign in to comment.