[cfe-dev] collecting source code information

Dominik Grewe dominik.grewe at gmail.com
Thu Jun 24 10:19:02 PDT 2010


Hey!

I'd like to write a program that collects statistics of OpenCL kernels. Examples
are the number of arithmetic operations, number and types of variables, etc. In
the future I'd also like to do some static analysis, for example to try and
derive memory access patterns.

I'm new to Clang, so I'm not quite sure how to go about this... It seems like
the RecursiveASTVisitor class could be a good start, as it allows you to
traverse the AST. Overloading VisitStmt() for example would allow me to count
the number of arithmetic expressions, right?
Unfortunately I can't figure out how to start the tree traversal. What is it
that I need to pass my visitor class in order to traverse the whole file or a
certain function?
Are there any examples that show a usage of RecursiveASTVisitor?

Thanks
Dominik





More information about the cfe-dev mailing list