vgvassilev / clad

clad -- automatic differentiation for C/C++
GNU Lesser General Public License v3.0
280 stars 123 forks source link

Model the source locations pointing to the primal function #932

Open vgvassilev opened 3 months ago

vgvassilev commented 3 months ago

In many cases when we generate code (mostly for template instantiation) we require valid source locations. We have a notion of a non-existent but valid source locations that we call fake locations.

The issue as pointed out by @vaithak in #930 it is more useful to point to the valid code to hint at possible breakages. That change of strategy will require updates throughout the codebase.

We should somehow try to position the source locations in the gradient, too. Currently, I am thinking that we could create another TextDiagnosticClient which can dump the generated AST into a memory buffer and position the diagnostics into the generated text. However, that would be of a limited use when things break at generation time, and will have limited use when debugging the programs because we will not have a textual representation of the symbols...