Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
https://codechecker.readthedocs.io
Apache License 2.0
2.15k stars 358 forks source link

How is compilation database JSON file searched when a source file is given as analysis input when running CodeChecker analyze? #4194

Open w3ntao opened 3 months ago

w3ntao commented 3 months ago

It is said in the document Analyzer User Guide#analyze that:

In case a source file or a project directory is given as analysis input, the process still relies on the compilation database JSON file, because CodeChecker tries to find it implicitly.

But how exactly is compilation database JSON file found (implicitly)?

bruntib commented 3 months ago

CodeChecker is traversing parent directories of a source file up to the root directory. If any of those contains a file named compile_commands.json, then that will be used for the analysis of the given source file. Therefore, the documentation suggests placing the compile_commands.json in the analyzed project's directory.