Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy-diff fails locating some header files #2479

Open
battlmonstr opened this issue Nov 5, 2024 · 0 comments
Open

clang-tidy-diff fails locating some header files #2479

battlmonstr opened this issue Nov 5, 2024 · 0 comments

Comments

@battlmonstr
Copy link
Contributor

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

battlmonstr added a commit that referenced this issue Nov 5, 2024
see #2479

also: use CLion's clang-tidy on macOS
It requires "builtin includes" located at "../lib/clang/19/include"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant