system file dependencies for a part of the code using libtooling

Hello,

I have been trying to find the system file dependencies for a part of the code within a single c file. A sample scenario will be-

-There are 3 functions in file f1.c- func1(), func2() and func3()
-the file f1.c had a number of system header files included
-I use clang to take func2() from f1.c and move it to a new file f2.c
-To do this I need to understand which all system headers present in f1.c are being used by func2() so that I can add these also to f2.c

I have looked at all functions which I could use from the clang API and I cannot see any way I can get this information. Does anyone know of any functionality which will help achieve this??

Regards,
Deepak

You can take a look at include-what-you-use.
https://code.google.com/p/include-what-you-use/

Note that it has problems; we hope to get a better solution when we have modules.