[cfe-dev] How does scan-build

Christian Gagneraud via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 18 03:47:29 PDT 2019

On Thu, 18 Jul 2019 at 22:27, Paulo Matos <pmatos at linki.tools> wrote:
> On 18/07/2019 12:21, Christian Gagneraud via cfe-dev wrote:
> > On Thu, 18 Jul 2019 at 22:15, Дилян Палаузов <dpa-llvm at aegee.org> wrote:
> >> Hello Christin,
> >>
> >> I want to understand how the clang static analyzer is used, and https://clang-analyzer.llvm.org/scan-build.html says to
> >> use directly “scan-build”.
> > This documentation *might* be out-dated. What build system are you
> > using, that is the key question.
> > It's way easier to use the clang compilation database  -- if your
> > build system supports it --
> >
> > https://clang.llvm.org/docs/JSONCompilationDatabase.html
> Hi,
> I am interested in this as well and I am confused by what you are
> saying. Even if a compilation database is used with cmake for example,
> you still need to perform the analysis on the file in the compilation
> database. What am I missing here? Is there a tool besides scan-build
> that reads the compilation database and performs the analysis? I know of
> https://github.com/rizsotto/scan-build but this is not even part of the
> LLVM project so I assume there's something else you know about.

The modern way of working is first to start with a clang compilation database.
So you need to generate one with cmake, qbs, meson, whatever your
build system is.

Then any modern llvm-based tooling should/will understand this DB.
Clang static anylisers (clang-tidy, clazy, ...) come with some handy
python scripts that you might want to look into.

More information about the cfe-dev mailing list