[PATCH] get access to all files of compilation database

Hej,

when implementing some static code analysis tool based on clang, you often
want to introspect the complete code base of a project. With the current API,
you have to specify the list of files explicitly by passing them as second
parameter to the constructor of tooling::ClangTool and
the common approach seems to be to pass in this list as command line
parameters to your application.
Now I wonder whether the CompilationDatabase class (which has loaded all the
compilation information from compile_commands.json already) could provide a
getter method to retrieve the list of files and passing it to
tooling::ClangTool directly.

Attached is a patch for that. No idea how to handle the usage of
FixedCompilationDatabase in this case though.

Any suggestions, objections, comments?

Ciao,
Tobias

compilationdatabase.patch (2.77 KB)

Hej,

when implementing some static code analysis tool based on clang, you often
want to introspect the complete code base of a project. With the current API,
you have to specify the list of files explicitly by passing them as second
parameter to the constructor of tooling::ClangTool and
the common approach seems to be to pass in this list as command line
parameters to your application.
Now I wonder whether the CompilationDatabase class (which has loaded all the
compilation information from compile_commands.json already) could provide a
getter method to retrieve the list of files and passing it to
tooling::ClangTool directly.

Attached is a patch for that. No idea how to handle the usage of
FixedCompilationDatabase in this case though.

Any suggestions, objections, comments?

LGTM

apart from "." missing at the end of the \brief comments :slight_smile:

Do you have commit access?

> Any suggestions, objections, comments?

Hej Manuel,

LGTM

apart from "." missing at the end of the \brief comments :slight_smile:

Do you have commit access?

Unfortunately not, can you or somebody else commit it for me, please?
(including the missing "." ;)).

Please not that the patch has been created against the tooling branch and not
trunk.

Ciao,
Tobias

> Any suggestions, objections, comments?

Hej Manuel,

LGTM

apart from "." missing at the end of the \brief comments :slight_smile:

Do you have commit access?

Unfortunately not, can you or somebody else commit it for me, please?
(including the missing "." ;)).

Please not that the patch has been created against the tooling branch and not
trunk.

One more thing I notice is missing: a unit test for the
JSONCompilationDatabase::getAllFiles :slight_smile:
If you need help where to put that, let me know ...

Cheers,
/Manuel

Hej again,

One more thing I notice is missing: a unit test for the
JSONCompilationDatabase::getAllFiles :slight_smile:
If you need help where to put that, let me know ...

Attached is a new version of the patch with unit tests for
JSONCompilationDatabase and FixedCompilationDatabase.

Ciao,
Tobias

completiondatabase.patch (4.74 KB)

Hej again,

One more thing I notice is missing: a unit test for the
JSONCompilationDatabase::getAllFiles :slight_smile:
If you need help where to put that, let me know ...

Attached is a new version of the patch with unit tests for
JSONCompilationDatabase and FixedCompilationDatabase.

Thx. Submitted as r160167.
I edited the test for the JSON part to have all the information about
what's tested in the actual test.

Cheers,
/Manuel