libclang: missing some statements in the AST?

Hi all,

I’m new to libclang, recently I wrote a program for testing parsing, basically it output the ast to stdout. But when I run it over some source file, there are some statements missing? I can’t figure out what happened. The question was originally posted at stackoverflow, but no reply until now :slight_smile: Can any one give me some hints? Thanks very much.

The problem’s link: http://stackoverflow.com/questions/14250754/libclang-missing-some-statements-in-the-ast

Sincerely Yours,

Jayven

The problem is that parsing is failing due to missing a stddef.h, so
the lines that fail to parse aren't in the AST. I can get it to work
on my system by running it like this:

./parse_ast -I/usr/local/bin/../lib/clang/3.3/include tt.c

There is some info on this at
http://clang.llvm.org/docs/LibTooling.html#builtin-includes. This
problem comes up a lot, so you could also search the list archive for
stddef.h for more discussion of it.

It works, thx a lot !!

2013/1/11 Philip Craig <philipjcraig@gmail.com>

you might want to add some error handling, see page 15:

http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf