erigontech / erigontech/silkworm

clang-tidy-diff fails locating some header files

Open
#2,479 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
318
Forks
84
PR merge metrics
No merged PRs in 30d

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
| ^~~~~~~~~~

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](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.