Debian Codegraph @

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

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