1 : // Copyright 2013 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #include <stdlib.h>
16 :
17 : // This is a simple function that will contain a jump and case table. It has
18 : // C linkage so that the name is not mangled for easy lookup in unittests.
19 m : extern "C" int TestFunctionWithNoPrivateSymbols() {
20 m : int i = rand();
21 m : switch (i % 140) {
22 m : case 0:
23 m : case 11:
24 m : case 100:
25 m : case 101:
26 m : case 102: {
27 m : i += 5;
28 m : break;
29 m : }
30 :
31 m : case 1:
32 m : case 7:
33 m : case 80:
34 m : case 87: {
35 m : i -= 3;
36 m : break;
37 m : }
38 :
39 m : case 2:
40 m : case 6: {
41 m : i += rand();
42 m : break;
43 m : }
44 :
45 m : case 3:
46 m : case 9: {
47 m : i %= 8;
48 m : break;
49 m : }
50 :
51 m : case 4:
52 m : case 10: {
53 m : i /= 2;
54 m : break;
55 m : }
56 :
57 m : case 5:
58 m : case 8:
59 m : case 43:
60 m : case 44: {
61 m : i *= 17;
62 m : break;
63 m : }
64 :
65 m : default: {
66 m : i >>= 2;
67 m : break;
68 m : }
69 m : }
70 :
71 m : if (i % 2) {
72 m : i *= 3;
73 m : } else {
74 m : --i;
75 m : }
76 :
77 m : return i;
78 m : }
|