Skip to content

Commit

Permalink
Fix clang tidy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristin22 committed Oct 8, 2024
1 parent 2ddb902 commit eacd11e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
25 changes: 12 additions & 13 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
// arrays are not stored.
bool passByRef = PVD->getType()->isReferenceType() &&
!isa<MaterializeTemporaryExpr>(arg);
Expr* argDiffStore;
Expr* argDiffStore = nullptr;
if (passByRef && !argDiff.getExpr()->isEvaluatable(m_Context))
argDiffStore =
GlobalStoreAndRef(argDiff.getExpr(), "_t", /*force=*/true);
Expand Down Expand Up @@ -2370,7 +2370,7 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
std::string customPushforward = FD->getNameAsString() + "_pushforward";
auto pushforwardCallArgs = DerivedCallArgs;
pushforwardCallArgs.push_back(ConstantFolder::synthesizeLiteral(
DerivedCallArgs.front()->getType(), m_Context, 1));
DerivedCallArgs.front()->getType(), m_Context, /*val=*/1));
OverloadedDerivedFn = m_Builder.BuildCallToCustomDerivativeKernel(
customPushforward, pushforwardCallArgs, getCurrentScope(),
const_cast<DeclContext*>(FD->getDeclContext()), config);
Expand Down Expand Up @@ -2619,17 +2619,16 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
NumDiffArgs.push_back(args[i]);
}
std::string Name = "central_difference";
if (config)
return m_Builder.BuildCallToCustomDerivativeKernel(
Name, NumDiffArgs, getCurrentScope(), /*OriginalFnDC=*/nullptr,
config,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false);
else
return m_Builder.BuildCallToCustomDerivativeOrNumericalDiff(
Name, NumDiffArgs, getCurrentScope(), /*OriginalFnDC=*/nullptr,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false);
return config ? m_Builder.BuildCallToCustomDerivativeKernel(
Name, NumDiffArgs, getCurrentScope(),
/*OriginalFnDC=*/nullptr, config,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false)
: m_Builder.BuildCallToCustomDerivativeOrNumericalDiff(
Name, NumDiffArgs, getCurrentScope(),
/*OriginalFnDC=*/nullptr,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false);
}

StmtDiff ReverseModeVisitor::VisitUnaryOperator(const UnaryOperator* UnOp) {
Expand Down
21 changes: 10 additions & 11 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,17 +756,16 @@ namespace clad {
NumDiffArgs.insert(NumDiffArgs.end(), args.begin(), args.begin() + numArgs);
// Return the found overload.
std::string Name = "forward_central_difference";
if (config)
return m_Builder.BuildCallToCustomDerivativeKernel(
Name, NumDiffArgs, getCurrentScope(), /*OriginalFnDC=*/nullptr,
config,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false);
else
return m_Builder.BuildCallToCustomDerivativeOrNumericalDiff(
Name, NumDiffArgs, getCurrentScope(), /*OriginalFnDC=*/nullptr,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false);
return config ? m_Builder.BuildCallToCustomDerivativeKernel(
Name, NumDiffArgs, getCurrentScope(),
/*OriginalFnDC=*/nullptr, config,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false)
: m_Builder.BuildCallToCustomDerivativeOrNumericalDiff(
Name, NumDiffArgs, getCurrentScope(),
/*OriginalFnDC=*/nullptr,
/*forCustomDerv=*/false,
/*namespaceShouldExist=*/false);
}

void VisitorBase::CallExprDiffDiagnostics(const clang::FunctionDecl* FD,
Expand Down

0 comments on commit eacd11e

Please sign in to comment.