clang documents

Dear collegues,
      I would like to study clang for code analysis research. For
example, I need to traverse and even instrument the generated AST.
      However, I am now a beginner to clang. I don't know where to
start, e.g. reading its code base. I would like to know if somebody
has documents on clang's architecture and modules. I don't think that
clang API documents (http://clang.llvm.org/doxygen/) are good for
beginners. Maybe I need more detailed explainations. Please give me
some suggestions.
      Thanks!

Best regards,

Z.C.

Dear collegues,
       I would like to study clang for code analysis research. For
example, I need to traverse and even instrument the generated AST.
       However, I am now a beginner to clang. I don't know where to
start, e.g. reading its code base. I would like to know if somebody
has documents on clang's architecture and modules. I don't think that
clang API documents (http://clang.llvm.org/doxygen/) are good for
beginners. Maybe I need more detailed explainations. Please give me
some suggestions.
       Thanks!

Have you examined the documentation on the Clang web page (such as http://clang.llvm.org/docs/InternalsManual.html)?

-- John T.

I'm finding it useful to stick to the C interface to Clang, as opposed to jumping straight
in to the full codebase. The C interface is I guess meant to be minimal but fairly
complete, so it's a lot easier to follow the intended usages, and to get familiar
with what are the core components.

Writing some sample code using just the APIs exposed in 'include/clang-c/Index.h'
is, I think, the easiest way to get going.

Kevin

Yes, I have carefully read the full internals Manual. I think
that it only introduces the major internal design decisions made in
Clang, rather than detailed modules or classes. But I am trying to
understand the architecture of Clang's codebase.
    About the C interface to Clang in 'include/clang-c/Index.h', I
have some questions:
1. where can I find the implementation of the functions defined in index.h ?
2. how these C style interfaces can be used ? where can I find some examples?

I have some more questions about clang:
1. what is the relationship between clang/include/clang-c/index.h and
clang/tools/libclang ?
2. what does CINDEX_LINKAGE mean in index.h ?
3. Is there any example of using the libclang in C++ programs ?

Thanks!

1. The implementation of the functions in index.h is located here: http://llvm.org/svn/llvm-project/cfe/trunk/tools/libclang/

2. Here are some API documentation of the C functions:
http://clang.llvm.org/doxygen/modules.html

Here are two talks about clang that can be used as documentation:

Slides: http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf
Video: http://devimages.apple.com/llvm/videos/Libclang.mov

Slides: http://llvm.org/devmtg/2011-11/Gregor_ExtendingClang.pdf
Video: http://devimages.apple.com/llvm/videos/ExtendingClang.m4v

This is a project I'm working on using clang. It's a source-to-source translator that translate Objective-C/C code to D. It's written in D but it should be that hard to understand and follow.

https://github.com/jacob-carlborg/dstep