mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 02:26:38 +00:00

Previously, bitwise shifts with constant operands were validated by the checker `core.UndefinedBinaryOperatorResult`. However, this logic was unreliable, and commit 25b9696b61e53a958e217bb3d0eab66350dc187f added the dedicated checker `core.BitwiseShift` which validated the preconditions of all bitwise shifts with a more accurate logic (that uses the real types from the AST instead of the unreliable type information encoded in `APSInt` objects). This commit disables the inaccurate logic that could mark bitwise shifts as 'undefined' and removes the redundant shift-related warning messages from core.UndefinedBinaryOperatorResult. The tests that were validating this logic are also deleted by this commit; but I verified that those testcases trigger the expected bug reports from `core.BitwiseShift`. (I didn't convert them to tests of `core.BitwiseShift`, because that checker already has its own extensive test suite with many analogous testcases.) I hope that there will be a time when the constant folding will be reliable, but until then we need hacky solutions like this improve the quality of results.
16 lines
346 B
C
16 lines
346 B
C
// RUN: %clang_analyze_cc1 %s \
|
|
// RUN: -analyzer-checker=core \
|
|
// RUN: -analyzer-checker=debug.ExprInspection \
|
|
// RUN: -verify
|
|
|
|
// Here, we test that svalbuilder simplification does not produce any
|
|
// assertion failure.
|
|
|
|
// expected-no-diagnostics
|
|
|
|
void crashing(long a, _Bool b) {
|
|
(void)(a & 1 && 0);
|
|
b = a & 1;
|
|
(void)(b << 1);
|
|
}
|