1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/reorder/test.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +extern "C" int mult(int l, int r); 1.9 + 1.10 +extern "C" { 1.11 + 1.12 +inline 1.13 +int 1.14 +farfle(int a, int b) 1.15 +{ 1.16 + return a * b + a / b; 1.17 +} 1.18 + 1.19 +static 1.20 +int 1.21 +ballywhoo(int a, int b) 1.22 +{ 1.23 + // So it can't get inlined 1.24 + if (a > 4) 1.25 + ballywhoo(a - 1, a + 1); 1.26 + 1.27 + return a + b; 1.28 +} 1.29 + 1.30 +static 1.31 +int 1.32 +blimpyburger(char a, int b) 1.33 +{ 1.34 + if (a == 'f') 1.35 + return b; 1.36 + 1.37 + return 0; 1.38 +} 1.39 + 1.40 +} 1.41 + 1.42 +class foo 1.43 +{ 1.44 +public: 1.45 + static int get_flooby() { static int flooby = 12; return flooby; } 1.46 + 1.47 + static int divide(int a, int b); 1.48 + 1.49 + foo() {} 1.50 + foo(int a); 1.51 + virtual ~foo() {} 1.52 + 1.53 + int bar(); 1.54 + 1.55 + int baz(int a) { return a ? baz(a - 1) : 0; } 1.56 +}; 1.57 + 1.58 +foo::foo(int a) 1.59 +{ 1.60 +} 1.61 + 1.62 +int 1.63 +foo::divide(int a, int b) 1.64 +{ 1.65 + static int phlegm = 12; 1.66 + return a / b * ++phlegm; 1.67 +} 1.68 + 1.69 +int 1.70 +foo::bar() 1.71 +{ 1.72 + return 12; 1.73 +} 1.74 + 1.75 +int main(int argc, char* argv[]) 1.76 +{ 1.77 + int a = mult(5, 4); 1.78 + a = ballywhoo(5, 2); 1.79 + a = farfle(a, 6); 1.80 + a = blimpyburger('q', 4); 1.81 + 1.82 + foo f; 1.83 + f.get_flooby(); 1.84 + a = f.bar(); 1.85 + 1.86 + a = foo::divide(a, 12) + f.baz(6); 1.87 + 1.88 + foo f2(12); 1.89 + f2.baz(15); 1.90 + 1.91 + return a > 99 ? 1 : 0; 1.92 +}