clang-tidy-diff fails locating some header files #2479
Description
In particular: gmock.h, mdbx.h++
The error looks like this:
/home/circleci/project/silkworm/db/datastore/mdbx/mdbx.hpp:29:10: error: 'mdbx.h++' file not found [clang-diagnostic-error]
29 | #include <mdbx.h++>
| ^~~~~~~~~~
227323 warnings and 1 error generated.
Error while processing /home/circleci/project/silkworm/db/data_store.hpp.
Reason is that clang-tidy-diff finds include paths using compile_commands.json file generated via cmake CMAKE_EXPORT_COMPILE_COMMANDS. That option only supports exporting .cpp files. It contains no info about "standalone" .hpp files.
Analyzing .hpp files is currently disabled on master in clang-tidy-diff.sh -exclude
expression. This means that if a PR changes only an .hpp file, but doesn't change any .cpp files that include that .hpp file, the .hpp file won't be checked.
In order to fix this, the compile_commands.json must contain commands for .hpp files as well. cmake doesn't support it, but some other tools exist, see:
https://github.com/Sarcasm/compdb
https://stackoverflow.com/questions/73367767/how-to-get-compile-commands-json-right-for-header-only-library-using-cmake
Activity