Getting started

Hi,

I'm new to clang and am looking for some pointers on getting started.

I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?

Thanks

Phil

Hi,

I'm new to clang and am looking for some pointers on getting started.

See: http://llvm.org/docs/GettingStarted.html

I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?

See: http://llvm.org/docs/

Hi Chad,

I should have mentioned that I've already looked at the documents on llvm.org/docs and clang.llvm.org/docs.

I've also seen the doxygen API documentation, but it's going to take a long time to get going using that on its own :wink:
Phil.

Phil,
You might also try grepping the mailing lists to see if you can find an answer. Unfortunately, I don't have a specific answer to give you, but maybe someone else can offer some direction. If this is going to be a research project, then it's inevitable that you'll have to work on the source. That _is_ the definitive documentation.

Chad

Hello Phil,

This maybe the blind leading the blind, but have you seen Douglas' talk about libclang (http://llvm.org/devmtg/2011-11/index.html) and extending clang the year before (http://llvm.org/devmtg/2010-11/)?

There's an example extracting function names in the example directory. I'd also study c-index-test source, which does AST walking.

Hope that get you started, Ed.

Hi,

I'm new to clang and am looking for some pointers on getting started.

I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?

Thanks

Phil

Hello Phil,

This maybe the blind leading the blind, but have you seen Douglas' talk
about libclang (http://llvm.org/devmtg/2011-11/index.html) and extending
clang the year before (http://llvm.org/devmtg/2010-11/)?

There's an example extracting function names in the example directory.
I'd also study c-index-test source, which does AST walking.

Hope that get you started, Ed.

If you want to build a code checking tool, then libclang is probably not the best thing for you. It is designed for things like IDEs and does not expose the code flow analysis stuff that the static analyser uses. Your best bet would probably be to look at the existing analysers.

David

-- Sent from my Cray X1

Thanks, I've had a look and that does look a better place to start.

Is there a "how to" for adding a new checker? I've added in a new cpp file and added it to cmakelists.txt, but it fails at compile time due a missing declaration in clang:ento. I think I just need to add something in to checkers.td - does it matter where ?

Phil.

Found the answer at clang-analyser.llvm.org/checker_dev_manual.html

Phil.