reorder.carbon 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/reorder.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/reorder.carbon
  10. class Class {
  11. fn G() -> i32 {
  12. return Class.F();
  13. }
  14. fn F() -> i32 {
  15. return 1;
  16. }
  17. }
  18. // CHECK:STDOUT: --- reorder.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  22. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  23. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  24. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  25. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  26. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  27. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  28. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  29. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  30. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = %Core
  36. // CHECK:STDOUT: .Class = %Class.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  39. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  40. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  41. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: class @Class {
  45. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  46. // CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32]
  47. // CHECK:STDOUT: %.loc12_13.1: type = value_of_initializer %int.make_type_32.loc12 [template = i32]
  48. // CHECK:STDOUT: %.loc12_13.2: type = converted %int.make_type_32.loc12, %.loc12_13.1 [template = i32]
  49. // CHECK:STDOUT: %return.var.loc12: ref i32 = var <return slot>
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  52. // CHECK:STDOUT: %int.make_type_32.loc16: init type = call constants.%Int32() [template = i32]
  53. // CHECK:STDOUT: %.loc16_13.1: type = value_of_initializer %int.make_type_32.loc16 [template = i32]
  54. // CHECK:STDOUT: %.loc16_13.2: type = converted %int.make_type_32.loc16, %.loc16_13.1 [template = i32]
  55. // CHECK:STDOUT: %return.var.loc16: ref i32 = var <return slot>
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = constants.%Class
  60. // CHECK:STDOUT: .G = %G.decl
  61. // CHECK:STDOUT: .F = %F.decl
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: fn @G() -> i32 {
  67. // CHECK:STDOUT: !entry:
  68. // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  69. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, @Class.%F.decl [template = constants.%F]
  70. // CHECK:STDOUT: %F.call: init i32 = call %F.ref()
  71. // CHECK:STDOUT: %.loc13_21.1: i32 = value_of_initializer %F.call
  72. // CHECK:STDOUT: %.loc13_21.2: i32 = converted %F.call, %.loc13_21.1
  73. // CHECK:STDOUT: return %.loc13_21.2
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @F() -> i32 {
  77. // CHECK:STDOUT: !entry:
  78. // CHECK:STDOUT: %.loc17: i32 = int_literal 1 [template = constants.%.3]
  79. // CHECK:STDOUT: return %.loc17
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: