blob: 0d7596a2a1a200dba05f75c8147d5fb614571eeb [file] [log] [blame]
David Brazdil8a7c0fe2015-11-02 20:24:55 +00001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17public class Main {
18
19 // Workaround for b/18051191.
20 class InnerClass {}
21
22 static boolean $inline$False() { return false; }
23
24 // DCE should only merge blocks where the first ends with a Goto.
25 // SSAChecker will fail if the following Throw->TryBoundary blocks are merged.
26 public static void doNotMergeThrow(String str) {
27 try {
28 throw new Exception(str);
29 } catch (Exception ex) {
30 return;
31 }
32 }
33
34 // Test deletion of all try/catch blocks. Multiple catch blocks test deletion
35 // where TryBoundary still has exception handler successors after having removed
36 // some already.
37
Aart Bik2767f4b2016-10-28 15:03:53 -070038 /// CHECK-START: void Main.testDeadTryCatch(boolean) dead_code_elimination$after_inlining (after)
David Brazdil8a7c0fe2015-11-02 20:24:55 +000039 /// CHECK-NOT: TryBoundary
40
Aart Bik2767f4b2016-10-28 15:03:53 -070041 /// CHECK-START: void Main.testDeadTryCatch(boolean) dead_code_elimination$after_inlining (after)
David Brazdil8a7c0fe2015-11-02 20:24:55 +000042 /// CHECK: begin_block
43 /// CHECK: begin_block
44 /// CHECK: begin_block
45 /// CHECK-NOT: begin_block
46
47 public static void testDeadTryCatch(boolean val) {
48 if ($inline$False()) {
49 try {
50 if (val) {
51 throw new ArithmeticException();
52 } else {
53 throw new ArrayIndexOutOfBoundsException();
54 }
55 } catch (ArithmeticException ex) {
56 System.out.println("Unexpected AE catch");
57 } catch (ArrayIndexOutOfBoundsException ex) {
58 System.out.println("Unexpected AIIOB catch");
59 }
60 }
61 }
62
63 public static void main(String[] args) {
64
65 }
Aart Bik2767f4b2016-10-28 15:03:53 -070066}