Hi,
I am implementing refactorings in CDT using clang (or llvm?) as the analysis engine. I am planning to write these library functions on top of clang, and then using native calls to communicate with them. Here are some specific things that I want to perform.
a) Given two variables, ask analysis engine if they are aliases or not.
b) Given a variable, find about its points-to-set.
c) Given a variable, follow its def-use chain.
d) Given a function, follow its call graph.
e) Given a cursor, browse the AST. The AST may involve multiple files.
etc…
The analysis should be inter-procedural.
These are not written as optimization passes, but should be function calls that are like queries.
Please guide me as to: 1) whether I need to use llvm or clang, 2) which parts of clang/llvm should I concentrate on.
Thanks in advance.
Munawar
Hi,
I am implementing refactorings in CDT using clang (or llvm?) as the analysis engine. I am planning to write these library functions on top of clang, and then using native calls to communicate with them. Here are some specific things that I want to perform.
a) Given two variables, ask analysis engine if they are aliases or not.
b) Given a variable, find about its points-to-set.
If you want pointer analysis, you'll probably need LLVM's analysis. Mapping that information back to Clang's ASTs will be nontrivial, though.
c) Given a variable, follow its def-use chain.
d) Given a function, follow its call graph.
These could be constructed on top of Clang, although def-use information would be limited to the simple cases.
e) Given a cursor, browse the AST. The AST may involve multiple files.
This can be done with Clang (or even libclang, the C interface). It's by far the easiest, Clang-only thing to do.
- Doug