1 // RUN: %clang_analyze_cc1 \
2 // RUN: -analyzer-checker=debug.ExprInspection \
3 // RUN: -verify %s 2>&1 | FileCheck %s
5 // Self-tests for the debug.ExprInspection checker.
7 void clang_analyzer_dump(int x
);
8 void clang_analyzer_dump_pointer(int *p
);
9 void clang_analyzer_dumpSvalType(int x
);
10 void clang_analyzer_dumpSvalType_pointer(int *p
);
11 void clang_analyzer_printState(void);
12 void clang_analyzer_numTimesReached(void);
15 clang_analyzer_dump(x
); // expected-warning{{reg_$0<int x>}}
16 clang_analyzer_dump(x
+ (-1)); // expected-warning{{(reg_$0<int x>) - 1}}
17 clang_analyzer_dumpSvalType(x
); // expected-warning {{int}}
21 clang_analyzer_numTimesReached(); // expected-warning{{2}}
26 clang_analyzer_printState();
31 // CHECK: "program_state": {
32 // CHECK-NEXT: "store": { "pointer": "{{0x[0-9a-f]+}}", "items": [
33 // CHECK-NEXT: { "cluster": "y", "pointer": "{{0x[0-9a-f]+}}", "items": [
34 // CHECK-NEXT: { "kind": "Direct", "offset": {{[0-9]+}}, "value": "2 S32b" }
37 // CHECK-NEXT: "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [
38 // CHECK-NEXT: { "lctx_id": {{[0-9]+}}, "location_context": "#0 Call", "calling": "foo", "location": null, "items": [
39 // CHECK-NEXT: { "stmt_id": {{[0-9]+}}, "kind": "ImplicitCastExpr", "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
42 // CHECK-NEXT: "constraints": [
43 // CHECK-NEXT: { "symbol": "reg_$0<int x>", "range": "{ [-2147483648, 13] }" }
45 // CHECK-NEXT: "equivalence_classes": null,
46 // CHECK-NEXT: "disequality_info": null,
47 // CHECK-NEXT: "dynamic_types": null,
48 // CHECK-NEXT: "dynamic_casts": null,
49 // CHECK-NEXT: "checker_messages": null
56 void test_field_dumps(struct S s
, struct S
*p
) {
57 clang_analyzer_dump_pointer(&s
.x
); // expected-warning{{&s.x}}
58 clang_analyzer_dump_pointer(&p
->x
); // expected-warning{{&Element{SymRegion{reg_$1<struct S * p>},0 S64b,struct S}.x}}
59 clang_analyzer_dumpSvalType_pointer(&s
.x
); // expected-warning {{int *}}