Skip to content

Commit d5be2bf

Browse files
committed
Add test demonstrating the correct order
This test also demonstrates that all sorts of bindings can be printed in the right order. Direct, Default, and Symbolic bindings. Also testing the order of the Clusters. Memory spaces come first in alphabetical order then the regular clusters.
1 parent 7c20b11 commit d5be2bf

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s 2>&1 | FileCheck %s
2+
// expected-no-diagnostics
3+
4+
void clang_analyzer_printState();
5+
6+
struct Member {
7+
int large[10];
8+
};
9+
Member getMember();
10+
11+
struct Class {
12+
Member m;
13+
int first;
14+
int second;
15+
int third;
16+
};
17+
18+
19+
void test_output(int n) {
20+
Class objsecond;
21+
objsecond.m.large[n] = 20;
22+
23+
Class objfirst;
24+
25+
objfirst.m = getMember();
26+
objfirst.second = 2;
27+
objfirst.third = 3;
28+
objfirst.first = 1;
29+
30+
clang_analyzer_printState();
31+
// Default binding is before any direct bindings.
32+
// Direct bindings are increasing by offset.
33+
// Global memory space clusters come before any other clusters.
34+
// Otherwise, Clusters are in alphabetical order.
35+
36+
// CHECK: "store": { "pointer": "0x{{[0-9a-f]+}}", "items": [
37+
// CHECK-NEXT: { "cluster": "GlobalInternalSpaceRegion", "pointer": "0x{{[0-9a-f]+}}", "items": [
38+
// CHECK-NEXT: { "kind": "Default", "offset": 0, "value": "conj_$
39+
// CHECK-NEXT: ]},
40+
// CHECK-NEXT: { "cluster": "GlobalSystemSpaceRegion", "pointer": "0x{{[0-9a-f]+}}", "items": [
41+
// CHECK-NEXT: { "kind": "Default", "offset": 0, "value": "conj_$
42+
// CHECK-NEXT: ]},
43+
// CHECK-NEXT: { "cluster": "objfirst", "pointer": "0x{{[0-9a-f]+}}", "items": [
44+
// CHECK-NEXT: { "kind": "Default", "offset": 0, "value": "lazyCompoundVal
45+
// CHECK-NEXT: { "kind": "Direct", "offset": 320, "value": "1 S32b" },
46+
// CHECK-NEXT: { "kind": "Direct", "offset": 352, "value": "2 S32b" },
47+
// CHECK-NEXT: { "kind": "Direct", "offset": 384, "value": "2 S32b" }
48+
// CHECK-NEXT: ]},
49+
// CHECK-NEXT: { "cluster": "objsecond", "pointer": "0x{{[0-9a-f]+}}", "items": [
50+
// CHECK-NEXT: { "kind": "Default", "offset": 0, "value": "0 S32b" },
51+
// CHECK-NEXT: { "kind": "Direct", "offset": null, "value": "20 S32b" }
52+
// CHECK-NEXT: ]}
53+
// CHECK-NEXT: ]},
54+
55+
(void)objfirst;
56+
(void)objsecond;
57+
}

0 commit comments

Comments
 (0)