[cfe-dev] Compilation Database format

Pierrick Bouvier bouvier.pierrick at yahoo.fr
Sun Mar 1 16:51:01 PST 2015


Hello Clang community,

I am currently working on a tool able to generate a compilation database
by catching all exec done, something similar to
https://github.com/rizsotto/Bear but with the end goal of providing more
than just this feature to user (I want to use libclang for providing
autocompletion, refactoring, stats and other stuff related to user's
codebase, independently of any editor or IDE).

I really like the idea of compilation database, and I have a few
questions that were not answered by the manual page:
http://clang.llvm.org/docs/JSONCompilationDatabase.html

Those are my questions:
1) Is that possible to provide a cwd relative to compilation database
file itself? What I aim is possibility for user to move his source
folder from place without having to use sed or regenerate the
compilation database. For example, if compilation database is
"/my/project/compilation_database.json" and my source is in
"/my/project/src/main.cpp" I want to offer cwd as "src/" and source file
as "main.cpp". Is this correct and more than all, is that supported by
libclang?
2) Is that possible to extend compilation_database without breaking
libclang? I would like to add a list of fields named "dependency" to
precise which files the source depends on. This can be used for creating
statistics or simply to know if file (or any dep) has changed without
having to preprocess, thus enabling speedlight on big projects.
For example:
   - cwd "src/"
   - file "main.cpp"
   - command ...
   - dependency "/usr/include/stdio.h"
   - dependency "/usr/include/stdlib.h"

If those feature are not possible with current libclang, and if you
agree, I can work on a patch to make this possible.

Thank you, and thank you again for providing clang/llvm to people.
Pierrick



More information about the cfe-dev mailing list