Source file test/fuse.go

     1  // errorcheck -0 -d=ssa/late_fuse/debug=1
     2  
     3  //go:build (amd64 && !gcflags_noopt) || (arm64 && !gcflags_noopt)
     4  
     5  // Copyright 2021 The Go Authors. All rights reserved.
     6  // Use of this source code is governed by a BSD-style
     7  // license that can be found in the LICENSE file.
     8  
     9  package main
    10  
    11  import "strings"
    12  
    13  const Cf2 = 2.0
    14  
    15  func fEqEq(a int, f float64) bool {
    16  	return a == 0 && f > Cf2 || a == 0 && f < -Cf2 // ERROR "Redirect Eq64 based on Eq64$"
    17  }
    18  
    19  func fEqNeq(a int32, f float64) bool {
    20  	return a == 0 && f > Cf2 || a != 0 && f < -Cf2 // ERROR "Redirect Neq32 based on Eq32$"
    21  }
    22  
    23  func fEqLess(a int8, f float64) bool {
    24  	return a == 0 && f > Cf2 || a < 0 && f < -Cf2
    25  }
    26  
    27  func fEqLeq(a float64, f float64) bool {
    28  	return a == 0 && f > Cf2 || a <= 0 && f < -Cf2
    29  }
    30  
    31  func fEqLessU(a uint, f float64) bool {
    32  	return a == 0 && f > Cf2 || a < 0 && f < -Cf2
    33  }
    34  
    35  func fEqLeqU(a uint64, f float64) bool {
    36  	return a == 0 && f > Cf2 || a <= 0 && f < -Cf2 // ERROR "Redirect Eq64 based on Eq64$"
    37  }
    38  
    39  func fNeqEq(a int, f float64) bool {
    40  	return a != 0 && f > Cf2 || a == 0 && f < -Cf2 // ERROR "Redirect Eq64 based on Neq64$"
    41  }
    42  
    43  func fNeqNeq(a int32, f float64) bool {
    44  	return a != 0 && f > Cf2 || a != 0 && f < -Cf2 // ERROR "Redirect Neq32 based on Neq32$"
    45  }
    46  
    47  func fNeqLess(a float32, f float64) bool {
    48  	// TODO: Add support for floating point numbers in prove
    49  	return a != 0 && f > Cf2 || a < 0 && f < -Cf2
    50  }
    51  
    52  func fNeqLeq(a int16, f float64) bool {
    53  	return a != 0 && f > Cf2 || a <= 0 && f < -Cf2 // ERROR "Redirect Leq16 based on Neq16$"
    54  }
    55  
    56  func fNeqLessU(a uint, f float64) bool {
    57  	return a != 0 && f > Cf2 || a < 0 && f < -Cf2
    58  }
    59  
    60  func fNeqLeqU(a uint32, f float64) bool {
    61  	return a != 2 && f > Cf2 || a <= 2 && f < -Cf2 // ERROR "Redirect Leq32U based on Neq32$"
    62  }
    63  
    64  func fLessEq(a int, f float64) bool {
    65  	return a < 0 && f > Cf2 || a == 0 && f < -Cf2
    66  }
    67  
    68  func fLessNeq(a int32, f float64) bool {
    69  	return a < 0 && f > Cf2 || a != 0 && f < -Cf2
    70  }
    71  
    72  func fLessLess(a float32, f float64) bool {
    73  	return a < 0 && f > Cf2 || a < 0 && f < -Cf2 // ERROR "Redirect Less32F based on Less32F$"
    74  }
    75  
    76  func fLessLeq(a float64, f float64) bool {
    77  	return a < 0 && f > Cf2 || a <= 0 && f < -Cf2
    78  }
    79  
    80  func fLeqEq(a float64, f float64) bool {
    81  	return a <= 0 && f > Cf2 || a == 0 && f < -Cf2
    82  }
    83  
    84  func fLeqNeq(a int16, f float64) bool {
    85  	return a <= 0 && f > Cf2 || a != 0 && f < -Cf2 // ERROR "Redirect Neq16 based on Leq16$"
    86  }
    87  
    88  func fLeqLess(a float32, f float64) bool {
    89  	return a <= 0 && f > Cf2 || a < 0 && f < -Cf2
    90  }
    91  
    92  func fLeqLeq(a int8, f float64) bool {
    93  	return a <= 0 && f > Cf2 || a <= 0 && f < -Cf2 // ERROR "Redirect Leq8 based on Leq8$"
    94  }
    95  
    96  func fLessUEq(a uint8, f float64) bool {
    97  	return a < 0 && f > Cf2 || a == 0 && f < -Cf2
    98  }
    99  
   100  func fLessUNeq(a uint16, f float64) bool {
   101  	return a < 0 && f > Cf2 || a != 0 && f < -Cf2
   102  }
   103  
   104  func fLessULessU(a uint32, f float64) bool {
   105  	return a < 0 && f > Cf2 || a < 0 && f < -Cf2
   106  }
   107  
   108  func fLessULeqU(a uint64, f float64) bool {
   109  	return a < 0 && f > Cf2 || a <= 0 && f < -Cf2
   110  }
   111  
   112  func fLeqUEq(a uint8, f float64) bool {
   113  	return a <= 2 && f > Cf2 || a == 2 && f < -Cf2 // ERROR "Redirect Eq8 based on Leq8U$"
   114  }
   115  
   116  func fLeqUNeq(a uint16, f float64) bool {
   117  	return a <= 2 && f > Cf2 || a != 2 && f < -Cf2 // ERROR "Redirect Neq16 based on Leq16U$"
   118  }
   119  
   120  func fLeqLessU(a uint32, f float64) bool {
   121  	return a <= 0 && f > Cf2 || a < 0 && f < -Cf2
   122  }
   123  
   124  func fLeqLeqU(a uint64, f float64) bool {
   125  	return a <= 2 && f > Cf2 || a <= 2 && f < -Cf2 // ERROR "Redirect Leq64U based on Leq64U$"
   126  }
   127  
   128  // Arg tests are disabled because the op name is different on amd64 and arm64.
   129  
   130  func fEqPtrEqPtr(a, b *int, f float64) bool {
   131  	return a == b && f > Cf2 || a == b && f < -Cf2 // ERROR "Redirect EqPtr based on EqPtr$"
   132  }
   133  
   134  func fEqPtrNeqPtr(a, b *int, f float64) bool {
   135  	return a == b && f > Cf2 || a != b && f < -Cf2 // ERROR "Redirect NeqPtr based on EqPtr$"
   136  }
   137  
   138  func fNeqPtrEqPtr(a, b *int, f float64) bool {
   139  	return a != b && f > Cf2 || a == b && f < -Cf2 // ERROR "Redirect EqPtr based on NeqPtr$"
   140  }
   141  
   142  func fNeqPtrNeqPtr(a, b *int, f float64) bool {
   143  	return a != b && f > Cf2 || a != b && f < -Cf2 // ERROR "Redirect NeqPtr based on NeqPtr$"
   144  }
   145  
   146  func fEqInterEqInter(a interface{}, f float64) bool {
   147  	return a == nil && f > Cf2 || a == nil && f < -Cf2 // ERROR "Redirect IsNonNil based on IsNonNil$"
   148  }
   149  
   150  func fEqInterNeqInter(a interface{}, f float64) bool {
   151  	return a == nil && f > Cf2 || a != nil && f < -Cf2
   152  }
   153  
   154  func fNeqInterEqInter(a interface{}, f float64) bool {
   155  	return a != nil && f > Cf2 || a == nil && f < -Cf2
   156  }
   157  
   158  func fNeqInterNeqInter(a interface{}, f float64) bool {
   159  	return a != nil && f > Cf2 || a != nil && f < -Cf2 // ERROR "Redirect IsNonNil based on IsNonNil$"
   160  }
   161  
   162  func fEqSliceEqSlice(a []int, f float64) bool {
   163  	return a == nil && f > Cf2 || a == nil && f < -Cf2 // ERROR "Redirect IsNonNil based on IsNonNil$"
   164  }
   165  
   166  func fEqSliceNeqSlice(a []int, f float64) bool {
   167  	return a == nil && f > Cf2 || a != nil && f < -Cf2
   168  }
   169  
   170  func fNeqSliceEqSlice(a []int, f float64) bool {
   171  	return a != nil && f > Cf2 || a == nil && f < -Cf2
   172  }
   173  
   174  func fNeqSliceNeqSlice(a []int, f float64) bool {
   175  	return a != nil && f > Cf2 || a != nil && f < -Cf2 // ERROR "Redirect IsNonNil based on IsNonNil$"
   176  }
   177  
   178  func fPhi(a, b string) string {
   179  	aslash := strings.HasSuffix(a, "/") // ERROR "Redirect Phi based on Phi$"
   180  	bslash := strings.HasPrefix(b, "/")
   181  	switch {
   182  	case aslash && bslash:
   183  		return a + b[1:]
   184  	case !aslash && !bslash:
   185  		return a + "/" + b
   186  	}
   187  	return a + b
   188  }
   189  
   190  func main() {
   191  }
   192  

View as plain text