matus-chochlik / ctcache

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

Questions regarding integration with codechecker #23

Open olologin opened 1 year ago

olologin commented 1 year ago

Hello, I am trying to integrate your caching wrapper with codechecker (https://github.com/Ericsson/codechecker), and I see some strange issues, all of which I can fix locally myself, but I still would like to mention these problems:

1) Why is adjust_chunk method not ignoring lines that start with '#' ? Is there a reason why those lines can matter? I think in general adjust_chunk should not try to replace anything in preprocessed code, it is usable for command line arguments but not for source code. 2) I think _omit_after(ct_args, ["-export-fixes"] should be adjusted to work with --export-fixes as well 3) It seems command for clang-tidy that is generated by codechecker is quite special and current wrapper does not expect such command: /usr/lib/llvm-15/bin/clang-tidy /build/asd/file.cpp --export-fixes /build/asd/build/reports_clang-tidy/fixit/file.yaml -- -Qunused-arguments -Wall -Wextra -x c++ --target=x86_64-pc-linux-gnu -DBOOST_NO_AUTO_PTR -DBOOST_NO_CXX11_UNICODE_LITERALS -DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE="/usr/lib/gcc/x86_64-linux-gnu/10/include/backtrace.h" -DBOOST_STACKTRACE_USE_BACKTRACE -DEIGEN_MPL2_ONLY -DUNICODE -D_UNICODE -I/build/asd/dev/libraries/mwstd/public -isystem /build/asd/dev/third_party/boost_1_78 -g -fPIC -fexperimental-library -fdata-sections -ffunction-sections -fexceptions -ftrapping-math -stdlib=libc++ -fvisibility-ms-compat -fopenmp=libomp -std=c++20 -isystem /usr/lib/llvm-15/include/c++/v1 -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include

- First issue happens because there is no compiler command after -- (no `clang++-15` for example), and wrapper does not add its own compiler command
- Second issue happens because `-E` is not added if there is no `-c` in input
-  Third issue happens because there is no actual cpp file mentioned in the second part of command (after --)

The question: Are you aware of all this? Does it make sense to fix all of this? I think I can help with fixing if you want.

matus-chochlik commented 1 year ago

Hi,

  1. I don't remember why the check in adjust_chunk is "# " instead of just "#", you can try if using just the latter doesn't break anything and if it doesn't, feel free to fix it. The reason why the preprocessed code is adjusted is that I had been working on a project with ~25 developers, where we had ct_cache on a shared server. The preprocessor adds lines that contain paths like "/some/prefix/to/code/repo/include/filename.cpp" for one developer and "/another/prefix/to/code/repo/include/filename.cpp" these preprocesed files are otherwise identical from the C++ standpoint and we wanted to get the same hashes for them, so that multiple people could share the cached results.

  2. feel free to add "--export-fixes" to the list

  3. I know that some tools invoke clang-tidy with different CL arguments. Currently it supports the arg formats from projects where I was involved. If you can fix it so that it supports your use-case without breaking the others feel free to do the necessary changes and submit a PR, I'll be happy to merge it.

thanks