I am doing interprocedural data flow analysis using clang. I am currently using libtooling to parse the source files and invoke the visitor AST. The question is how to create one AST for multiple .c files?
I tried using the ASTImport class, but does not support importing some AST nodes. Moreover, I am doing something wrong when I create and process CompilerIstance, and it crashes in the destructor.
A very similar option was ASTImportAction, but it is not entirely clear to me which command-line options should be passed to ClangTool in this case.
The third option is to create ASTUnits for each .c file and look for definitions in each of them, it is unclear how to find a correspondence between the types of user definitions, for example. records. At ASTImport, they use the IsStructurallyEquivalent () function, but are declared in an anonymous namespace, so I can copy all this code into my program. Again, it does not support all AST nodes.
From the Internet, this link http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-August/023865.html seems most appropriate, but for me the technical details of the solution are not clear.
Any suggestions are welcome. Many thanks.
c clang static-analysis abstract-syntax-tree
Julia Demyanova
source share