Skip to content

Commit

Permalink
Don't use original stmts in the generated code.
Browse files Browse the repository at this point in the history
It's not correct to use the original expressions ``L`` and ``R`` in the generated code. Also, it doesn't make sense why we exclusively differentiate ``DeclRefExpr``.
  • Loading branch information
PetroZarytskyi authored and vgvassilev committed Jan 23, 2025
1 parent 6b3f919 commit d4d29d8
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2316,15 +2316,7 @@ Expr* ReverseModeVisitor::getStdInitListSizeExpr(const Expr* E) {
BinOp->getEndLoc(),
"derivative of an assignment attempts to assign to unassignable "
"expr, assignment ignored");
auto* LDRE = dyn_cast<DeclRefExpr>(L);
auto* RDRE = dyn_cast<DeclRefExpr>(R);

if (!LDRE && !RDRE)
return Clone(BinOp);
Expr* LExpr = LDRE ? Visit(L).getRevSweepAsExpr() : L;
Expr* RExpr = RDRE ? Visit(R).getRevSweepAsExpr() : R;

return BuildOp(opCode, LExpr, RExpr);
return Clone(BinOp);
}

// Visit LHS, but delay emission of its derivative statements, save them
Expand Down

0 comments on commit d4d29d8

Please sign in to comment.