Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
https://codechecker.readthedocs.io
Apache License 2.0
2.15k stars 358 forks source link

CodeChecker analyze skip does not work if the file location is relative in the compilation db #4223

Closed dkrupp closed 1 month ago

dkrupp commented 2 months ago

When the --file parameter is referred with an absolute path, but the compilation database contains the file as a relative path to the directory member e.g. tests/FLP37-C-A.c in this example the file is not recognized.

Reproduction: Compilation db:

[{
        "directory": "/workspace/sei_cert_test_suite/cpp",
        "command": "/usr/bin/gcc -Itests -c tests/FLP37-C-A.c -o obj/FLP37-C-A.o",
        "file": "tests/FLP37-C-A.c"
}]
CodeChecker analyze --output /local/workspace/sei_cert_test_suite/.codechecker/reports /local/workspace/sei_cert_test_suite/cpp/compile_commands.json --file /local/workspace/sei_cert_test_suite/cpp/tests/FLP37-C-A.c --analyzers clang-tidy clangsa -e cert
[INFO 2024-04-17 14:31] - No analysis is required.
There were no compilation commands in the provided compilation database or all of them were skipped.
>>> Process 'CodeChecker analyze' exited with code 0