-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Once the derivative's FunctionDecl is created it needs to be registered properly in the AST. Before this patch `registerDerivative` ignored many checks which make sure the produced code is valid C++. This patch enforces more rigorous checks for some declaration kinds such as standalone functions and some cases of class functions. Lambdas will be handled in subsequent patches. The challenge is to produce valid C++ code when differentiating classes. Consider: ```cpp class A1 { double f(double x) { return x * x; } double f_grad(double x, double *d_x); // forward declaration of the gradient. }; ``` In such cases clad will now produce a correct out-of-line definition of `f_grad`: `double A1::f_grad(double x, double *d_x) { ... }`. In cases where the gradient function is not declared as part of the class signature (external libraries such as STL), we continue to handle them as before. That will be dealt with in a subsequent patches. This also fixes assertions in debug mode when there are virtual functions.
- Loading branch information
1 parent
c2f1acf
commit 584eb31
Showing
12 changed files
with
136 additions
and
115 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
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
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
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
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
Oops, something went wrong.