Debian Codegraph @

clang/test/Profile/cxx-hash-v2.cpp

raw
1 // Check that all of the hashes in this file are unique (i.e, that none of the
2 // profiles for these functions are mutually interchangeable).
3 //
4 // RUN: llvm-profdata show -all-functions %S/Inputs/cxx-hash-v2.profdata.v5 | grep "Hash: 0x" | sort > %t.hashes
5 // RUN: uniq %t.hashes > %t.hashes.unique
6 // RUN: diff %t.hashes %t.hashes.unique
7
8 // RUN: llvm-profdata merge %S/Inputs/cxx-hash-v2.proftext -o %t.profdata
9 // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -allow-empty
10 // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%S/Inputs/cxx-hash-v2.profdata.v5 2>&1 | FileCheck %s -allow-empty
11
12 // CHECK-NOT: warning: profile data may be out of date
13
14 int x;
15 int arr[1] = {0};
16
17 void loop_after_if_else() {
18 if (1)
19 x = 1;
20 else
21 x = 2;
22 while (0)
23 ++x;
24 }
25
26 void loop_in_then_block() {
27 if (1) {
28 while (0)
29 ++x;
30 } else {
31 x = 2;
32 }
33 }
34
35 void loop_in_else_block() {
36 if (1) {
37 x = 1;
38 } else {
39 while (0)
40 ++x;
41 }
42 }
43
44 void if_inside_of_for() {
45 for (x = 0; x < 0; ++x) {
46 x = 1;
47 if (1)
48 x = 2;
49 }
50 }
51
52 void if_outside_of_for() {
53 for (x = 0; x < 0; ++x)
54 x = 1;
55 if (1)
56 x = 2;
57 }
58
59 void if_inside_of_while() {
60 while (0) {
61 x = 1;
62 if (1)
63 x = 2;
64 }
65 }
66
67 void if_outside_of_while() {
68 while (0)
69 x = 1;
70 if (1)
71 x = 2;
72 }
73
74 void nested_dos() {
75 do {
76 do {
77 ++x;
78 } while (0);
79 } while (0);
80 }
81
82 void consecutive_dos() {
83 do {
84 } while (0);
85 do {
86 ++x;
87 } while (0);
88 }
89
90 void loop_empty() {
91 for (x = 0; x < 5; ++x) {}
92 }
93
94 void loop_return() {
95 for (x = 0; x < 5; ++x)
96 return;
97 }
98
99 void loop_continue() {
100 for (x = 0; x < 5; ++x)
101 continue;
102 }
103
104 void loop_break() {
105 for (x = 0; x < 5; ++x)
106 break;
107 }
108
109 void no_gotos() {
110 static void *dispatch[] = {&&done};
111 x = 0;
112 done:
113 ++x;
114 }
115
116 void direct_goto() {
117 static void *dispatch[] = {&&done};
118 x = 0;
119 goto done;
120 done:
121 ++x;
122 }
123
124 void indirect_goto() {
125 static void *dispatch[] = {&&done};
126 x = 0;
127 goto *dispatch[x];
128 done:
129 ++x;
130 }
131
132 void nested_for_ranges() {
133 for (int a : arr)
134 for (int b : arr)
135 ++x;
136 }
137
138 void consecutive_for_ranges() {
139 for (int a : arr) {}
140 for (int b : arr)
141 ++x;
142 }
143
144 void nested_try_catch() {
145 try {
146 try {
147 ++x;
148 } catch (...) {}
149 } catch (...) {}
150 }
151
152 void consecutive_try_catch() {
153 try {} catch (...) {}
154 try {
155 ++x;
156 } catch (...) {}
157 }
158
159 void no_throw() {}
160
161 void has_throw() {
162 throw 0;
163 }
164
165 void single_lnot() {
166 if (!x) {}
167 }
168
169 void double_lnot() {
170 if (!!x) {}
171 }
172
173 int main() {
174 return 0;
175 }