bit_complement.carbon 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/bit_complement.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/bit_complement.carbon
  14. // This file was generated from unary_op.carbon.tmpl. Run make_tests.sh to regenerate.
  15. package User;
  16. class C {};
  17. impl C as Core.BitComplement where .Result = C {
  18. fn Op[self: C]() -> C {
  19. return {};
  20. }
  21. }
  22. fn TestOp(a: C) -> C {
  23. //@dump-sem-ir-begin
  24. return ^a;
  25. //@dump-sem-ir-end
  26. }
  27. // CHECK:STDOUT: --- bit_complement.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  31. // CHECK:STDOUT: %BitComplement.type: type = facet_type <@BitComplement> [concrete]
  32. // CHECK:STDOUT: %BitComplement.Op.type: type = fn_type @BitComplement.Op [concrete]
  33. // CHECK:STDOUT: %BitComplement.impl_witness: <witness> = impl_witness file.%BitComplement.impl_witness_table [concrete]
  34. // CHECK:STDOUT: %C.as.BitComplement.impl.Op.type: type = fn_type @C.as.BitComplement.impl.Op [concrete]
  35. // CHECK:STDOUT: %C.as.BitComplement.impl.Op: %C.as.BitComplement.impl.Op.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %BitComplement.facet: %BitComplement.type = facet_value %C, (%BitComplement.impl_witness) [concrete]
  37. // CHECK:STDOUT: %.c20: type = fn_type_with_self_type %BitComplement.Op.type, %BitComplement.facet [concrete]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: imports {
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @TestOp(%a.param: %C) -> %return.param: %C {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  46. // CHECK:STDOUT: %impl.elem1: %.c20 = impl_witness_access constants.%BitComplement.impl_witness, element1 [concrete = constants.%C.as.BitComplement.impl.Op]
  47. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %a.ref, %impl.elem1
  48. // CHECK:STDOUT: <elided>
  49. // CHECK:STDOUT: %C.as.BitComplement.impl.Op.call: init %C = call %bound_method(%a.ref) to %.loc27
  50. // CHECK:STDOUT: return %C.as.BitComplement.impl.Op.call to %return
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: