LibTooling CompilationDatabase

Hi,

I want to create a Tool integrated in another application therefore I won’t have a main function to call the tool. Which means I want to create the compilation database myself.
(I need the tool to translate from clang ast to another ast (in memory structure) for a visual representation of the code)

Do I need a CompilationDatabase anyway because I only want to do frontendactions (no compilation - just preprocessing and ast visiting) ?

From the documentation I got the structure that is needed for compilation database file but I don’t really understand what has to be in there.

Also I would like to know what actually happens internally by calling CompilationDatabase::loadFromDirectory(…)

Or would it be easier to just read the code in manually and then call runToolOnCode() ?

I would be happy if someone could clarify this whole thing a bit or point me to a Tutorial or some other example. (I looked through the clang Documentation pages but it didn’t help me so far)

Thanks in advance.

Cheers,

Lukas

Hi,

I want to create a Tool integrated in another application therefore I
won't have a main function to call the tool. Which means I want to create
the compilation database myself.
(I need the tool to translate from clang ast to another ast (in memory
structure) for a visual representation of the code)

Do I need a CompilationDatabase anyway because I only want to do
frontendactions (no compilation - just preprocessing and ast visiting) ?

Yes.

From the documentation I got the structure that is needed for compilation
database file but I don't really understand what has to be in there.

If you have your own way to determine the various flags needed, you don't
need to go through a file - you can just implement your own
CompilationDatabase that returns the right flags for the right files.

Also I would like to know what actually happens internally by calling
CompilationDatabase::loadFromDirectory(..)

Or would it be easier to just read the code in manually and then call
runToolOnCode() ?

I would be happy if someone could clarify this whole thing a bit or point
me to a Tutorial or some other example. (I looked through the clang
Documentation pages but it didn't help me so far)

Look at the source of CommonOptionsParser to see how to build up a
compilation database yourself / how you can inject your own compilation
database.

Cheers,
/Manuel