1#include <stdio.h>
2
3class ExcA {};
4class ExcB {};
5class ExcC {};
6class ExcD {};
7class ExcE {};
8class ExcF {};
9class ExcG {};
10
11void foo(int a)
12{
13 if (a > 1)
14 throw ExcG();
15 else
16 throw ExcC();
17}
18
19void never_throws() throw () {
20 printf(format: "this statement is cold and should be outlined\n");
21}
22
23int main(int argc, char **argv)
24{
25 for (unsigned i = 0; i < 1000; ++i) {
26 try {
27 if (argc == 2) {
28 never_throws(); // should be cold
29 }
30 try {
31 if (argc == 2) {
32 never_throws(); // should be cold
33 }
34 throw ExcA();
35 } catch (ExcA) {
36 printf(format: "catch 2\n");
37 throw new int();
38 }
39 } catch (...) {
40 printf(format: "catch 1\n");
41 }
42
43 try {
44 try {
45 foo(a: argc);
46 } catch (ExcC) {
47 printf(format: "caught ExcC\n");
48 }
49 } catch (ExcG) {
50 printf(format: "caught ExcG\n");
51 }
52 }
53
54 return 0;
55}
56

source code of bolt/test/runtime/X86/Inputs/exception4.cpp