tools/reorder/test.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 extern "C" int mult(int l, int r);
     7 extern "C" {
     9 inline
    10 int
    11 farfle(int a, int b)
    12 {
    13     return a * b + a / b;
    14 }
    16 static
    17 int
    18 ballywhoo(int a, int b)
    19 {
    20     // So it can't get inlined
    21     if (a > 4)
    22         ballywhoo(a - 1, a + 1);
    24     return a + b;
    25 }
    27 static
    28 int
    29 blimpyburger(char a, int b)
    30 {
    31     if (a == 'f')
    32         return b;
    34     return 0;
    35 }
    37 }
    39 class foo
    40 {
    41 public:
    42     static int get_flooby() { static int flooby = 12; return flooby; }
    44     static int divide(int a, int b);
    46     foo() {}
    47     foo(int a);
    48     virtual ~foo() {}
    50     int bar();
    52     int baz(int a) { return a ? baz(a - 1) : 0; }
    53 };
    55 foo::foo(int a)
    56 {
    57 }
    59 int
    60 foo::divide(int a, int b)
    61 {
    62     static int phlegm = 12;
    63     return a / b * ++phlegm;
    64 }
    66 int
    67 foo::bar()
    68 {
    69     return 12;
    70 }
    72 int main(int argc, char* argv[])
    73 {
    74     int a = mult(5, 4);
    75     a = ballywhoo(5, 2);
    76     a = farfle(a, 6);
    77     a = blimpyburger('q', 4);
    79     foo f;
    80     f.get_flooby();
    81     a = f.bar();
    83     a = foo::divide(a, 12) + f.baz(6);
    85     foo f2(12);
    86     f2.baz(15);
    88     return a > 99 ? 1 : 0;
    89 }

mercurial