2017-03-04 02:02:02 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s 2>&1 | FileCheck %s
|
2016-12-01 01:57:18 +08:00
|
|
|
|
|
|
|
// Self-tests for the debug.ExprInspection checker.
|
|
|
|
|
|
|
|
void clang_analyzer_dump(int x);
|
|
|
|
void clang_analyzer_printState();
|
|
|
|
void clang_analyzer_numTimesReached();
|
|
|
|
|
|
|
|
void foo(int x) {
|
2016-12-06 04:30:11 +08:00
|
|
|
clang_analyzer_dump(x); // expected-warning{{reg_$0<int x>}}
|
2017-10-19 19:58:21 +08:00
|
|
|
clang_analyzer_dump(x + (-1)); // expected-warning{{(reg_$0<int x>) + -1}}
|
2016-12-01 01:57:18 +08:00
|
|
|
int y = 1;
|
|
|
|
clang_analyzer_printState();
|
|
|
|
for (; y < 3; ++y)
|
|
|
|
clang_analyzer_numTimesReached(); // expected-warning{{2}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: Store (direct and default bindings)
|
|
|
|
// CHECK-NEXT: (y,0,direct) : 1 S32b
|
|
|
|
|
2018-02-09 06:24:38 +08:00
|
|
|
// CHECK: Expressions by stack frame:
|
|
|
|
// CHECK-NEXT: #0 Calling foo
|
2016-12-01 01:57:18 +08:00
|
|
|
// CHECK-NEXT: clang_analyzer_printState : &code{clang_analyzer_printState}
|
2018-02-09 06:24:38 +08:00
|
|
|
|
|
|
|
// CHECK: {{(Ranges are empty.)|(Constraints:[[:space:]]*$)}}
|