[cfe-dev] Extracting the include tree from a source file
broeksema at kde.org
Mon Nov 15 10:17:08 CST 2010
For a small program  I'm working on to analyze physical properties of a
C++ project, I'm interested in integrating clang. The first (and I think
relative simple) step I'd like to take is using clang to extract the
My program already has an internal project graph containing source files,
object files, executables and (external) libraries. This graph I want to
complete with the headers.
So my question is, what is the easiest way, using clang (programmatically)
to extract the include tree given a path to a source file, a list of include
directories (i.e. the one past to the compiler, not internal paths) and a
list of defines (again, only the defines past to the compiler).
I attached some initial code I'm playing with (not integrated with the rest
of my program, just to get a feeling on how to use clang). Currently it
somewhat works, but it doesn't find system includes (i.e. the headers that
the compiler normally internally resolves) and if something goes wrong, e.g.
a header is not found, it just plain crashes. Also, its not clear to me how
to set defines and finally most important, how to actually get the include
tree after (or during?) preprocessing.
Any help is appreciated.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2192 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20101115/1799b4f7/attachment.bin
More information about the cfe-dev