llvm / llvm/llvm-project

analyze-build: incorrect exit code when using --sarif and --status-bugs

Open
#162,037 3 comments 0 reactions 0 assignees View on GitHub
clang:static analyzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

### Description

I get an exit code of 0 when I run `analyze-build --sarif --status-bugs` on any codebase that has analyzer warnings. The exit code is non-zero if I use `--plist` or `--sarif-html` instead of `--sarif`.

The root cause seems to be that the bug reporting code only analyzes .plist and .html files for bug entries:
https://github.com/llvm/llvm-project/blob/dd3c26a045c081620375a878159f536758baba6e/clang/tools/scan-build-py/lib/libscanbuild/report.py#L348-L357

### Version info
clang version 20.1.8 on Arch Linux

Contributor guide

Open the contributing guide

Research direction

Start in clang/tools/scan-build-py/lib/libscanbuild/report.py around lines 348-357 and reproduce the issue with analyze-build --sarif --status-bugs on a codebase with analyzer warnings. Compare its exit code with --plist and --sarif-html; done means SARIF output also returns a non-zero status when bugs are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.