Skip to content

Commit

Permalink
Add fixme comments for const_cast usage
Browse files Browse the repository at this point in the history
Co-authored-by: Vassil Vassilev <[email protected]>
  • Loading branch information
vaithak and vgvassilev committed Jun 15, 2024
1 parent 6d10934 commit e839e1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Differentiator/BaseForwardModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ BaseForwardModeVisitor::Derive(const FunctionDecl* FD,
// Check if the function is already declared as a custom derivative.
std::string gradientName =
request.BaseFunctionName + "_d" + s + "arg" + argInfo + derivativeSuffix;
// FIXME: We should not use const_cast to get the decl context here.
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
auto* DC = const_cast<DeclContext*>(m_DiffReq->getDeclContext());
if (FunctionDecl* customDerivative =
m_Builder.LookupCustomDerivativeDecl(gradientName, DC, FD->getType()))
Expand Down
2 changes: 2 additions & 0 deletions lib/Differentiator/HessianModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ static FunctionDecl* DeriveUsingForwardAndReverseMode(
originalFnProtoType->getExtProtoInfo());

// Check if the function is already declared as a custom derivative.
// FIXME: We should not use const_cast to get the decl context here.
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
auto* DC = const_cast<DeclContext*>(m_DiffReq->getDeclContext());
if (FunctionDecl* customDerivative = m_Builder.LookupCustomDerivativeDecl(
hessianFuncName, DC, hessianFunctionType))
Expand Down
2 changes: 2 additions & 0 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
originalFnType->getExtProtoInfo());

// Check if the function is already declared as a custom derivative.
// FIXME: We should not use const_cast to get the decl context here.
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
auto* DC = const_cast<DeclContext*>(m_DiffReq->getDeclContext());
if (FunctionDecl* customDerivative = m_Builder.LookupCustomDerivativeDecl(
gradientName, DC, gradientFunctionType)) {
Expand Down

0 comments on commit e839e1e

Please sign in to comment.