Add definitions of macros to `diffkemp-out.yaml`
This PR contains the last but one part of #314 (remains enhancements of viewer for visualisation of code/diff for macro-function/function-macro differences.
The PR adds extracted information about the location of macro definitions to the diffkemp-out.yaml file which is created when diffkemp compare is run. Thanks to the added macro definitions (and thanks to previously merged PRs) it will be now possible to see the code of the macros in the result viewer.
I'm quite confused by the new code and it seems over-complicated to me at this point. I'm not saying that it's not the best way, it's just that I'm failing to see why that's the case.
Yeah, it is probably over-complicated and probably also not very effective. There are probably better solutions, I did it like this to leave most of the logic the same and just at the end extract the necessary information (location of definitions) from places which contains them. Another ideas of how to do this which comes to my mind:
- Use
cscope/ctagsor something similar to extract the definition. I think, the problem with this would be that the symbols can have multiple definitions which are conditionally 'selected' during compilation. The correct definition could probably be deduced from the information saved in callstacks (using the place at which the symbol is called/used --> the definition must start somewhere above), but there would be still a problem in deducing the correct location of the definition for differing symbols. On the other hand, if we would want in the future to add to the viewer code navigation, we would still need to use something likectags/cscope... - Very similar solution to the current one -- add to
SyntaxDiffclassget_definitionsmethod which would extract the definitions from the callstack and which would add the definitions for differing symbols. Then theYamlOutputclass would need just to extract from the resulting callstacks names of differing macros and the name of function/vertex that uses the macros (similar to what is done for types). And the location of definitions would be extracted using theget_definitionsmethod onSyntaxDiffclass which would be found using the previously mentioned information. This solution would not be probably too much time effective too. - a) Accumulate the definitions already in the SimpLL library and serialize them to output and then cache them in the
ComparisonGraph. b) Caching the definitions inComparisonGraphwhen deserializing results from SimpLL library. - Save the definitions to
Resultclass when the functions are compared infunction_difffunction. InYamlOutputjust save the definitions from theResultclass. - ...
Not sure if all the ideas are implementable, just some options that came to my mind. I will need to more deeply think about this because I am not sure which approach to choose.
Yeah, it seems that there are many ways to do this. From the first glance, option 3 seems like the best but I think that we should have an in-person discussion on this to better understand what the problem is and what the best solution would be.