Linking files while using Clang AST matchers to implement a call graph
I am trying to implement an ability to keep track of reads and writes to a variables and objects. The object can be passed by reference or by pointer to other functions.
I am using CLang AST matcher for this task.
My solution seems to work, but only when all the functions are located in the same source file.
When functionA calls functionB, whose definition is located in another cpp file, I am unable to get the location of the definition of functionB, I only able to get the declaration which located in its header file.
My questions are:
How I can get to the definition to a callee function from a caller location which located in a different source file (different AST)?
Do I need to somehow pass the linkage stage to make it work?
I have seen in other posts that CLang libTooling does not support Cross Translation Unit feature.
I also seen that LibClang allowed to impenitent this by using Unified Symbol Resolution. Does libTooling offer something like that?
Is there any other option to getting to function definition when more than one source file is used?
I have searched the web for a few days to find any solution with no luck.
Any help will be much appreciated.
Here is more details about how and what I am trying to accomplish. It is a bit LONG so please don't read it if you don't have time:
I wrote two matchers:
One for matching all the write operations to a parameter inside a funcion: