matus-chochlik / ctcache

Cache for clang-tidy static analysis results
Boost Software License 1.0
84 stars 30 forks source link

Always include the Clang-Tidy config in the hash #70

Closed kaespi closed 3 months ago

kaespi commented 3 months ago

After thinking about the tool a bit, I concluded that the Clang-Tidy configuration also needs to be included in the hash. The (not so much documented) option --directories_with_clang_tidy=... could help there. However, I think that's not as handy as I want it to be. I think this has to be done by default. Furthermore, this flag could include configuration files which are even not of relevance for the processed file.

Therefore, I was hunting a more generic solution. My proposal here uses the Clang-Tidy tool itself. I'm asking it to dump the configuration for the file to be processed. In this way I don't have to scan for .clang-tidy files, but let Clang-Tidy handle that. This would even work if the user uses Clang-Tidy command line option --config-file.

Of course, the drawback of this solution is that it takes some time to execute Clang-Tidy to dump the config. Yet, it's unclear to me if that's much slower than reading and hashing all the .clang-tidy files. So if desired, we could add this as option.

matus-chochlik commented 3 months ago

Merged. Thanks for the PR.