-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support differentiating functions that return CXXConstructExpr.
The goal of the changes is to support ``ReturnStmt`` with ``CXXConstructExpr``, e.g. ``` SimpleFunctions1 operator*(const SimpleFunctions1& rhs) { return SimpleFunctions1(rhs.x, this->y); } ``` Currently, we have 2 problems in the way: 1) When forming the ``constructor_pullback`` call, we need to initialize a parameter of type ``SimpleFunctions1`` with a constructor. This is possible either with ``SimpleFunctions1(x, y)`` or with an ``InitListExpr`` ``{x, y}``. However, instead of doing the former, we generate a ``ParenListExpr`` ``(x, y)``. Clang can build the constructor call itself when dealing with decl inits but not here. 2) The pullback argument is not propagated to the constructor pullback; therefore, we get a zero derivative. This PR solves 2) completely and fixes 1) for usage in ``ReturnStmt`` and as a parameter.
- Loading branch information
1 parent
d13379d
commit 3b3749b
Showing
2 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters