Guidance: clang or llvm

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Guidance: clang or llvm

Munawar Hafiz
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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Guidance: clang or llvm

Douglas Gregor

On Dec 18, 2010, at 10:21 PM, Munawar Hafiz wrote:

> 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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Guidance: clang or llvm

Munawar Hafiz
Thanks a lot.

Munawar

On Tue, Dec 21, 2010 at 12:01 AM, Douglas Gregor <[hidden email]> wrote:

On Dec 18, 2010, at 10:21 PM, Munawar Hafiz wrote:

> 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


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev