Home | History | Annotate | Download | only in src
      1 /*
      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 
     17 
     18 public class Main {
     19 
     20   /// CHECK-START: void Main.boundTypeForIfNotNull() builder (after)
     21   /// CHECK-DAG:     <<Method:(i|j)\d+>>  CurrentMethod
     22   /// CHECK-DAG:     <<Null:l\d+>>        NullConstant
     23   /// CHECK-DAG:     <<Cst5:i\d+>>        IntConstant 5
     24   /// CHECK-DAG:     <<Cst10:i\d+>>       IntConstant 10
     25 
     26   /// CHECK-DAG:                          InvokeVirtual [<<NullCheck:l\d+>>]
     27   /// CHECK-DAG:     <<NullCheck>>        NullCheck [<<LoopPhi:l\d+>>] klass:int[]
     28   /// CHECK-DAG:     <<LoopPhi>>          Phi [<<Null>>,<<MergePhi:l\d+>>] klass:int[]
     29 
     30   /// CHECK-DAG:     <<BoundType:l\d+>>   BoundType [<<LoopPhi>>] klass:int[] can_be_null:false
     31   /// CHECK-DAG:     <<NewArray10:l\d+>>  NewArray [<<Cst10>>,<<Method>>] klass:int[]
     32   /// CHECK-DAG:     <<NotNullPhi:l\d+>>  Phi [<<BoundType>>,<<NewArray10>>] klass:int[]
     33 
     34   /// CHECK-DAG:     <<NewArray5:l\d+>>   NewArray [<<Cst5>>,<<Method>>] klass:int[]
     35   /// CHECK-DAG:     <<MergePhi>>         Phi [<<NewArray5>>,<<NotNullPhi>>] klass:int[]
     36 
     37   public static void boundTypeForIfNotNull() {
     38     int[] array = null;
     39     for (int i = -1; i < 10; ++i) {
     40       if (array == null) {
     41         array = new int[5];
     42       } else {
     43         if (i == 5) {
     44           array = new int[10];
     45         }
     46         array[i] = i;
     47       }
     48     }
     49     array.hashCode();
     50   }
     51 
     52   public static void main(String[] args) {  }
     53 }
     54