alias.carbon 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. namespace NS;
  7. alias ns = NS;
  8. fn NS.A() -> i32 { return 0; }
  9. fn B() -> i32 { return ns.A(); }
  10. alias C = NS.A;
  11. fn D() -> i32 { return C(); }
  12. // CHECK:STDOUT: --- alias.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %A: type = fn_type @A [template]
  16. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  17. // CHECK:STDOUT: %struct.1: A = struct_value () [template]
  18. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  19. // CHECK:STDOUT: %B: type = fn_type @B [template]
  20. // CHECK:STDOUT: %struct.2: B = struct_value () [template]
  21. // CHECK:STDOUT: %D: type = fn_type @D [template]
  22. // CHECK:STDOUT: %struct.3: D = struct_value () [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .Core = %Core
  28. // CHECK:STDOUT: .NS = %NS
  29. // CHECK:STDOUT: .ns = %ns
  30. // CHECK:STDOUT: .B = %B.decl
  31. // CHECK:STDOUT: .C = %C
  32. // CHECK:STDOUT: .D = %D.decl
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .A = %A.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %NS.ref.loc9: <namespace> = name_ref NS, %NS [template = %NS]
  39. // CHECK:STDOUT: %ns: <namespace> = bind_alias ns, %NS [template = %NS]
  40. // CHECK:STDOUT: %A.decl: A = fn_decl @A [template = constants.%struct.1] {
  41. // CHECK:STDOUT: @A.%return: ref i32 = var <return slot>
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %B.decl: B = fn_decl @B [template = constants.%struct.2] {
  44. // CHECK:STDOUT: @B.%return: ref i32 = var <return slot>
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %NS.ref.loc15: <namespace> = name_ref NS, %NS [template = %NS]
  47. // CHECK:STDOUT: %A.ref: A = name_ref A, %A.decl [template = constants.%struct.1]
  48. // CHECK:STDOUT: %C: A = bind_alias C, %A.decl [template = constants.%struct.1]
  49. // CHECK:STDOUT: %D.decl: D = fn_decl @D [template = constants.%struct.3] {
  50. // CHECK:STDOUT: @D.%return: ref i32 = var <return slot>
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @A() -> i32 {
  55. // CHECK:STDOUT: !entry:
  56. // CHECK:STDOUT: %.loc11: i32 = int_literal 0 [template = constants.%.2]
  57. // CHECK:STDOUT: return %.loc11
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @B() -> i32 {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %ns.ref: <namespace> = name_ref ns, file.%ns [template = file.%NS]
  63. // CHECK:STDOUT: %A.ref: A = name_ref A, file.%A.decl [template = constants.%struct.1]
  64. // CHECK:STDOUT: %A.call: init i32 = call %A.ref()
  65. // CHECK:STDOUT: %.loc13_30.1: i32 = value_of_initializer %A.call
  66. // CHECK:STDOUT: %.loc13_30.2: i32 = converted %A.call, %.loc13_30.1
  67. // CHECK:STDOUT: return %.loc13_30.2
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn @D() -> i32 {
  71. // CHECK:STDOUT: !entry:
  72. // CHECK:STDOUT: %C.ref: A = name_ref C, file.%C [template = constants.%struct.1]
  73. // CHECK:STDOUT: %A.call: init i32 = call %C.ref()
  74. // CHECK:STDOUT: %.loc17_27.1: i32 = value_of_initializer %A.call
  75. // CHECK:STDOUT: %.loc17_27.2: i32 = converted %A.call, %.loc17_27.1
  76. // CHECK:STDOUT: return %.loc17_27.2
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: