[clang] [analyzer] Remove inaccurate legacy handling of bad bitwise shifts (PR #66647)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 19 04:37:58 PDT 2023


DonatNagyE wrote:

The impact is limited, because `core.BitwiseShift` is a `PreStmt` callback, so when I merged it, it turned the logic tweaked/affected in this commit into "almost dead" code.

The most significant change is that some "pedantic-only" issues (i.e. code like `-1 >> 3` that's undefined behavior according to the standard, but works in practice) are no longer reported after this commit. (Note that I ran the evaluation with the default mode `core.BitwiseShift:Pedantic=false`, it's clear that pedantic mode would've reported these situations.) The change also elminates a few FPs, and sometimes new alpha.core.Conversion results appeared on branches that were previously stopped by a core.UndefinedBinaryOperator report.

Full results:

| Project | New reports | Lost reports | Difference |
| --- | --- | --- | --- |
| memcached | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=memcached_1.6.8_baseline&newcheck=memcached_1.6.8_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=memcached_1.6.8_baseline&newcheck=memcached_1.6.8_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| tmux | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=tmux_2.6_baseline&newcheck=tmux_2.6_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=tmux_2.6_baseline&newcheck=tmux_2.6_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| curl | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=curl_curl-7_66_0_baseline&newcheck=curl_curl-7_66_0_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=curl_curl-7_66_0_baseline&newcheck=curl_curl-7_66_0_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| twin | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=twin_v0.8.1_baseline&newcheck=twin_v0.8.1_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=twin_v0.8.1_baseline&newcheck=twin_v0.8.1_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| vim | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=vim_v8.2.1920_baseline&newcheck=vim_v8.2.1920_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=vim_v8.2.1920_baseline&newcheck=vim_v8.2.1920_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | one cryptic FP eliminated |
| openssl | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=openssl_openssl-3.0.0-alpha7_baseline&newcheck=openssl_openssl-3.0.0-alpha7_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=openssl_openssl-3.0.0-alpha7_baseline&newcheck=openssl_openssl-3.0.0-alpha7_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | one pedantic-only issue lost |
| sqlite | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=sqlite_version-3.33.0_baseline&newcheck=sqlite_version-3.33.0_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=sqlite_version-3.33.0_baseline&newcheck=sqlite_version-3.33.0_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| ffmpeg | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=ffmpeg_n4.3.1_baseline&newcheck=ffmpeg_n4.3.1_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=ffmpeg_n4.3.1_baseline&newcheck=ffmpeg_n4.3.1_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | 2 new, 7 lost [1] |
| postgres | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=postgres_REL_13_0_baseline&newcheck=postgres_REL_13_0_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=postgres_REL_13_0_baseline&newcheck=postgres_REL_13_0_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | 1 new, 2 lost [2] |
| tinyxml2 | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=tinyxml2_8.0.0_baseline&newcheck=tinyxml2_8.0.0_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=tinyxml2_8.0.0_baseline&newcheck=tinyxml2_8.0.0_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| libwebm | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=libwebm_libwebm-1.0.0.27_baseline&newcheck=libwebm_libwebm-1.0.0.27_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=libwebm_libwebm-1.0.0.27_baseline&newcheck=libwebm_libwebm-1.0.0.27_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| xerces | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=xerces_v3.2.3_baseline&newcheck=xerces_v3.2.3_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=xerces_v3.2.3_baseline&newcheck=xerces_v3.2.3_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| bitcoin | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=bitcoin_v0.20.1_baseline&newcheck=bitcoin_v0.20.1_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=bitcoin_v0.20.1_baseline&newcheck=bitcoin_v0.20.1_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |
| protobuf | [New reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=protobuf_v3.13.0_baseline&newcheck=protobuf_v3.13.0_remove_ubor_shifts&is-unique=on&diff-mode=New) | [Lost reports](https://codechecker.gic.ericsson.se/clangsa_checkers/reports?run=protobuf_v3.13.0_baseline&newcheck=protobuf_v3.13.0_remove_ubor_shifts&is-unique=on&diff-mode=Resolved) | no effect |


[1] [one alpha.core.Conversion result](https://codechecker.gic.ericsson.se/clangsa_checkers/report-detail?run=ffmpeg_n4.3.1_baseline&newcheck=ffmpeg_n4.3.1_remove_ubor_shifts&is-unique=on&diff-type=Resolved&report-id=124454106&report-hash=6b5c7929241c47564864796f59a7bdc6&report-filepath=%2asnow_dwt.c) lost for unclear reason, 4 pedantic-only results and 2 FPs eliminated, one of the pedantic-only results was replaced by two new alpha.core.Conversion results
[2] two pedantic-only issues not reported, one replaced by a new alpha.core.Conversion result

https://github.com/llvm/llvm-project/pull/66647


More information about the cfe-commits mailing list