On Mar 14, 2010, at 2:48 PM, Stefan Seefeld wrote:
> Hello,
>
> I'm looking at various bits of CLang code, trying to figure out the very
> first steps needed to:
>
> 1) parse a source file into an internal representation suitable for
> static code analysis.
> 2) navigate that representation (via CIndex, as Doug suggested).
CIndex can do both of these. clang_createTranslationUnitFromSourceFile(), part of the CIndex library, makes it easy to parse a source file into an AST.
> Can anyone give me some hints as to what specific API to use for this ?
clang_createTranslationUnitFromSourceFile() is the main entry point; clang_visitChildren() will let you walk the AST. That's most of it!
> Is there some documentation for this that I have overlooked ?
CIndex is documented here:
http://clang.llvm.org/doxygen/group__CINDEX.htmlthere's a little c-index-test program in Clang's source tree that shows how to load a source file and walk the AST, printing some information about the entities reached.
- Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev