dec.carbon 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. // This file was generated from unary_stmt.carbon.tmpl. Run make_tests.sh to regenerate.
  7. // --- prelude.carbon
  8. package Core api;
  9. interface Dec {
  10. fn Op[addr self: Self*]();
  11. }
  12. // --- user.carbon
  13. package User api;
  14. import Core;
  15. class C {};
  16. impl C as Core.Dec {
  17. fn Op[addr self: C*]();
  18. }
  19. fn TestOp() {
  20. var c: C = {};
  21. --c;
  22. }
  23. // CHECK:STDOUT: --- prelude.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %.1: type = interface_type @Dec [template]
  27. // CHECK:STDOUT: %.2: type = ptr_type Self [symbolic]
  28. // CHECK:STDOUT: %.3: type = assoc_entity_type @Dec, <function> [template]
  29. // CHECK:STDOUT: %.4: <associated <function> in Dec> = assoc_entity element0, @Dec.%Op [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  34. // CHECK:STDOUT: .Dec = %Dec.decl
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %Dec.decl: type = interface_decl @Dec [template = constants.%.1] {}
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: interface @Dec {
  40. // CHECK:STDOUT: %Self: Dec = bind_symbolic_name Self [symbolic]
  41. // CHECK:STDOUT: %Op: <function> = fn_decl @Op [template] {
  42. // CHECK:STDOUT: %Self.ref: Dec = name_ref Self, %Self [symbolic = %Self]
  43. // CHECK:STDOUT: %.loc5_24.1: type = facet_type_access %Self.ref [symbolic = %Self]
  44. // CHECK:STDOUT: %.loc5_20: type = converted %Self.ref, %.loc5_24.1 [symbolic = %Self]
  45. // CHECK:STDOUT: %.loc5_24.2: type = ptr_type Self [symbolic = constants.%.2]
  46. // CHECK:STDOUT: %self.loc5_14.1: Self* = param self
  47. // CHECK:STDOUT: %self.loc5_14.3: Self* = bind_name self, %self.loc5_14.1
  48. // CHECK:STDOUT: %.loc5_9: Self* = addr_pattern %self.loc5_14.3
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %.loc5_28: <associated <function> in Dec> = assoc_entity element0, %Op [template = constants.%.4]
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !members:
  53. // CHECK:STDOUT: .Self = %Self
  54. // CHECK:STDOUT: .Op = %.loc5_28
  55. // CHECK:STDOUT: witness = (%Op)
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Op[addr @Dec.%self.loc5_14.3: Self*]();
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: --- user.carbon
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: constants {
  63. // CHECK:STDOUT: %C: type = class_type @C [template]
  64. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  65. // CHECK:STDOUT: %.2: type = interface_type @Dec [template]
  66. // CHECK:STDOUT: %.3: type = ptr_type C [template]
  67. // CHECK:STDOUT: %.4: type = ptr_type Self [symbolic]
  68. // CHECK:STDOUT: %.5: <witness> = interface_witness (@impl.%Op) [template]
  69. // CHECK:STDOUT: %.6: type = tuple_type () [template]
  70. // CHECK:STDOUT: %.7: type = ptr_type {} [template]
  71. // CHECK:STDOUT: %.8: C = struct_value () [template]
  72. // CHECK:STDOUT: %.9: type = assoc_entity_type @Dec, <function> [template]
  73. // CHECK:STDOUT: %.10: <associated <function> in Dec> = assoc_entity element0, file.%import_ref.6 [template]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: file {
  77. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  78. // CHECK:STDOUT: .Core = %Core
  79. // CHECK:STDOUT: .C = %C.decl
  80. // CHECK:STDOUT: .TestOp = %TestOp
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  83. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  84. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, used [template = constants.%.2]
  85. // CHECK:STDOUT: %import_ref.2: <associated <function> in Dec> = import_ref ir1, inst+14, used [template = constants.%.10]
  86. // CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+3, unused
  87. // CHECK:STDOUT: %import_ref.4: <function> = import_ref ir1, inst+12, used [template = imports.%Op]
  88. // CHECK:STDOUT: impl_decl @impl {
  89. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  90. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
  91. // CHECK:STDOUT: %Dec.decl: invalid = interface_decl @Dec [template = constants.%.2] {}
  92. // CHECK:STDOUT: %Dec.ref: type = name_ref Dec, %import_ref.1 [template = constants.%.2]
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %TestOp: <function> = fn_decl @TestOp [template] {}
  95. // CHECK:STDOUT: %import_ref.5: type = import_ref ir1, inst+1, used [template = constants.%.2]
  96. // CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+12, unused
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: interface @Dec {
  100. // CHECK:STDOUT: !members:
  101. // CHECK:STDOUT: .Op = file.%import_ref.2
  102. // CHECK:STDOUT: .Self = file.%import_ref.3
  103. // CHECK:STDOUT: witness = (file.%import_ref.4)
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: impl @impl: C as Dec {
  107. // CHECK:STDOUT: %Op: <function> = fn_decl @Op.1 [template] {
  108. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  109. // CHECK:STDOUT: %.loc9_21: type = ptr_type C [template = constants.%.3]
  110. // CHECK:STDOUT: %self.loc9_14.1: C* = param self
  111. // CHECK:STDOUT: %self.loc9_14.3: C* = bind_name self, %self.loc9_14.1
  112. // CHECK:STDOUT: %.loc9_9: C* = addr_pattern %self.loc9_14.3
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %.1: <witness> = interface_witness (%Op) [template = constants.%.5]
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: !members:
  117. // CHECK:STDOUT: .Op = %Op
  118. // CHECK:STDOUT: witness = %.1
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: class @C {
  122. // CHECK:STDOUT: !members:
  123. // CHECK:STDOUT: .Self = constants.%C
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc9_14.3: C*]();
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: fn @Op.2[addr %self: Self*]();
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: fn @TestOp() {
  131. // CHECK:STDOUT: !entry:
  132. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  133. // CHECK:STDOUT: %c.var: ref C = var c
  134. // CHECK:STDOUT: %c: ref C = bind_name c, %c.var
  135. // CHECK:STDOUT: %.loc13_15.1: {} = struct_literal ()
  136. // CHECK:STDOUT: %.loc13_15.2: init C = class_init (), %c.var [template = constants.%.8]
  137. // CHECK:STDOUT: %.loc13_15.3: init C = converted %.loc13_15.1, %.loc13_15.2 [template = constants.%.8]
  138. // CHECK:STDOUT: assign %c.var, %.loc13_15.3
  139. // CHECK:STDOUT: %c.ref: ref C = name_ref c, %c
  140. // CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = @impl.%Op]
  141. // CHECK:STDOUT: %.loc14_3.1: <bound method> = bound_method %c.ref, %.1
  142. // CHECK:STDOUT: %.loc14_5: C* = addr_of %c.ref
  143. // CHECK:STDOUT: %.loc14_3.2: init () = call %.loc14_3.1(%.loc14_5)
  144. // CHECK:STDOUT: return
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: