
Summary: New logic tries to narrow possible result values of the remainder operation based on its operands and their ranges. It also tries to be conservative with negative operands because according to the standard the sign of the result is implementation-defined. rdar://problem/44978988 Differential Revision: https://reviews.llvm.org/D80117
29 lines
412 B
C++
29 lines
412 B
C++
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
void halt() __attribute__((__noreturn__));
|
|
void assert(int b) {
|
|
if (!b)
|
|
halt();
|
|
}
|
|
|
|
void decode(unsigned width) {
|
|
assert(width > 0);
|
|
|
|
int base;
|
|
bool inited = false;
|
|
|
|
int i = 0;
|
|
|
|
if (i % width == 0) {
|
|
base = 512;
|
|
inited = true;
|
|
}
|
|
|
|
base += 1; // no-warning
|
|
|
|
if (base >> 10)
|
|
assert(false);
|
|
}
|