2019-05-29 23:25:19 +08:00
|
|
|
// RUN: %clang_analyze_cc1 \
|
|
|
|
// RUN: -analyzer-checker=debug.ExprInspection \
|
|
|
|
// RUN: -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;
|
2019-05-29 23:25:19 +08:00
|
|
|
for (; y < 3; ++y) {
|
2016-12-01 01:57:18 +08:00
|
|
|
clang_analyzer_numTimesReached(); // expected-warning{{2}}
|
2019-05-29 23:25:19 +08:00
|
|
|
|
|
|
|
if (y == 2) {
|
|
|
|
int z = x > 13;
|
|
|
|
if (!z)
|
|
|
|
clang_analyzer_printState();
|
|
|
|
}
|
|
|
|
}
|
2016-12-01 01:57:18 +08:00
|
|
|
}
|
|
|
|
|
2019-05-30 00:22:21 +08:00
|
|
|
// CHECK: "program_state": {
|
|
|
|
// CHECK-NEXT: "store": [
|
|
|
|
// CHECK-NEXT: { "cluster": "y", "items": [
|
|
|
|
// CHECK-NEXT: { "kind": "Direct", "offset": 0, "value": "2 S32b" }
|
|
|
|
// CHECK-NEXT: ]}
|
|
|
|
// CHECK-NEXT: ],
|
|
|
|
// CHECK-NEXT: "environment": [
|
2019-06-20 07:33:48 +08:00
|
|
|
// CHECK-NEXT: { "lctx_id": 1, "location_context": "#0 Call", "calling": "foo", "call_line": null, "items": [
|
|
|
|
// CHECK-NEXT: { "stmt_id": {{[0-9]+}}, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
|
2019-05-30 00:22:21 +08:00
|
|
|
// CHECK-NEXT: ]}
|
|
|
|
// CHECK-NEXT: ],
|
|
|
|
// CHECK-NEXT: "constraints": [
|
|
|
|
// CHECK-NEXT: { "symbol": "reg_$0<int x>", "range": "{ [-2147483648, 13] }" }
|
|
|
|
// CHECK-NEXT: ],
|
|
|
|
// CHECK-NEXT: "dynamic_types": null,
|
|
|
|
// CHECK-NEXT: "constructing_objects": null,
|
|
|
|
// CHECK-NEXT: "checker_messages": null
|
|
|
|
// CHECK-NEXT: }
|
2019-05-30 00:02:33 +08:00
|
|
|
|