`clang-tidy` as a `clang` plugin: no assembly emitted

I’m trying to integrate clang-tidy in our build system. So far I’ve been using the CMake way.
The problem is that this introduces a ~1.7x build slowdown.

However, digging in the clang-tidy source code I noticed there’s a way to use it as a clang plugin.

This should significantly reduce the overhead, since there’s no need to parse the input files twice (once for clang-tidy and once for clang itself).

However, when I try to run it as a plugin, clang-tidy works fine but clang stops emitting any output:

$ ./bin/clang \
    -fplugin=./lib/libclangTidyPlugin.so.12 \
    -Xclang -plugin -Xclang clang-tidy  \
    -S \
    -o test \
    test.c
test.c:2:7: warning: invalid case style for variable 'a' [readability-identifier-naming]
  int a;
      ^
      A
1 warning generated.

I get a clang-tidy warning, but no assembly.

Is this expected?
Any suggestion on where to look to circumvent this issue?

1 Like