[cfe-dev] Static analyser for multiple files in clang

Nicholas Ng nickng at doc.ic.ac.uk
Mon Aug 20 08:36:41 PDT 2012


Hi,


I am writing a static analyser/type checker in clang, which needs to
follow the control flow of the source code, including going into bodies
of functions. It is currently implemented as an ASTConsumer and used as
a clang plugin. However, from what I understood, it works only for one
TranslationUnit/source file for each instance of the plugin, and I
intend to make it work for multiple source files as one single
program/AST.

So I am writing to the list to see whether anyone has tackled this
problem before and whether there are any 'best practices' or examples
for building static analysis tool with similar requirements?

I am looking at a few possibilities:

1. Merging ASTs from each source then run the analysis on the merged AST
2. Start analysing a 'main' AST and if something (eg. function body) is
missing, try search/walk other ASTs

Any directions would be much appreciated!


Many thanks,
Nicholas
-- 
Nicholas Ng
PhD Student
Department of Computing
Imperial College London
E: nickng at doc.ic.ac.uk
W: http://www.doc.ic.ac.uk/~cn06




More information about the cfe-dev mailing list