[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / expr-inspection.c
blob91c27f5b149f435fab93be406ca59d6c8244405a
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);
14 void foo(int x) {
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}}
19 int y = 1;
20 for (; y < 3; ++y) {
21 clang_analyzer_numTimesReached(); // expected-warning{{2}}
23 if (y == 2) {
24 int z = x > 13;
25 if (!z)
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" }
35 // CHECK-NEXT: ]}
36 // CHECK-NEXT: ]},
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}" }
40 // CHECK-NEXT: ]}
41 // CHECK-NEXT: ]},
42 // CHECK-NEXT: "constraints": [
43 // CHECK-NEXT: { "symbol": "reg_$0<int x>", "range": "{ [-2147483648, 13] }" }
44 // CHECK-NEXT: ],
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
50 // CHECK-NEXT: }
52 struct S {
53 int x, y;
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 *}}