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 357 forks source link

--ctu flag not handled during analysis #4233

Open mcserep opened 2 months ago

mcserep commented 2 months ago

Describe the bug The documentation states that Cross Translation Unit Analysis can be enabled with the --ctu flag. Using this flag is also included in the GitLab CI tutorial.

The flag is not recognized, instead the CodeChecker: error: unrecognized arguments: --ctu message is printed.

CodeChecker version 6.23.1

To Reproduce Steps to reproduce the behaviour:

  1. Run command: CodeChecker analyze --ctu -o ./reports ./compile_commands.json
  2. See error

Expected behaviour The Cross Translation Unit Analysis is performed when the --ctu flag is passed.

Desktop

whisperity commented 2 months ago

What is the Clang version on the machine? The --ctu flag is conditionally enabled based on the Clang available in the system. You'll need a new enough clang and clang-extdef-mapping in the PATH.

mcserep commented 2 months ago

Thanks for the quick response @whisperity. That was indeed the source of the issue. (Clang SA was not made properly available on the PATH due to some typo in the CI configuration I am working on.)

In that case I think the given error message is highly misleading, since CodeChecker has a separate error message for cases when clangsa (or any other analyzer) is not found on the PATH. In my opinion in this case that error message should have been printed, instead of stating that a documented flag (--ctu) is not recognized.

whisperity commented 2 months ago

Yeah the problems is that argparse hijacks the execution to throw a full error from parse_args() before we could detect the actual lack of CTU options... Will have to come up with a solution for this problem.