raw_identifier.carbon 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // ARGS: compile --no-prelude-import --phase=check --dump-sem-ir %s
  6. //
  7. // Check that the command-line flag to dump textual IR works.
  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/basics/no_prelude/raw_identifier.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/no_prelude/raw_identifier.carbon
  14. fn A(n: ()) -> () {
  15. return r#n;
  16. }
  17. fn B(r#n: ()) -> () {
  18. return n;
  19. }
  20. fn C(r#if: ()) -> () {
  21. return r#if;
  22. }
  23. // CHECK:STDOUT: --- raw_identifier.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  27. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  28. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  29. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  30. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  31. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  32. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .A = %A.decl
  38. // CHECK:STDOUT: .B = %B.decl
  39. // CHECK:STDOUT: .C = %C.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {
  42. // CHECK:STDOUT: %n.patt: %.1 = binding_pattern n
  43. // CHECK:STDOUT: %n.param_patt: %.1 = param_pattern %n.patt, runtime_param0
  44. // CHECK:STDOUT: } {
  45. // CHECK:STDOUT: %.loc15_10.1: %.1 = tuple_literal ()
  46. // CHECK:STDOUT: %.loc15_10.2: type = converted %.loc15_10.1, constants.%.1 [template = constants.%.1]
  47. // CHECK:STDOUT: %.loc15_17.1: %.1 = tuple_literal ()
  48. // CHECK:STDOUT: %.loc15_17.2: type = converted %.loc15_17.1, constants.%.1 [template = constants.%.1]
  49. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  50. // CHECK:STDOUT: %param: %.1 = param runtime_param0
  51. // CHECK:STDOUT: %n: %.1 = bind_name n, %param
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  54. // CHECK:STDOUT: %n.patt: %.1 = binding_pattern n
  55. // CHECK:STDOUT: %n.param_patt: %.1 = param_pattern %n.patt, runtime_param0
  56. // CHECK:STDOUT: } {
  57. // CHECK:STDOUT: %.loc19_12.1: %.1 = tuple_literal ()
  58. // CHECK:STDOUT: %.loc19_12.2: type = converted %.loc19_12.1, constants.%.1 [template = constants.%.1]
  59. // CHECK:STDOUT: %.loc19_19.1: %.1 = tuple_literal ()
  60. // CHECK:STDOUT: %.loc19_19.2: type = converted %.loc19_19.1, constants.%.1 [template = constants.%.1]
  61. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  62. // CHECK:STDOUT: %param: %.1 = param runtime_param0
  63. // CHECK:STDOUT: %n: %.1 = bind_name n, %param
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  66. // CHECK:STDOUT: %if.patt: %.1 = binding_pattern r#if
  67. // CHECK:STDOUT: %if.param_patt: %.1 = param_pattern %if.patt, runtime_param0
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %.loc23_13.1: %.1 = tuple_literal ()
  70. // CHECK:STDOUT: %.loc23_13.2: type = converted %.loc23_13.1, constants.%.1 [template = constants.%.1]
  71. // CHECK:STDOUT: %.loc23_20.1: %.1 = tuple_literal ()
  72. // CHECK:STDOUT: %.loc23_20.2: type = converted %.loc23_20.1, constants.%.1 [template = constants.%.1]
  73. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  74. // CHECK:STDOUT: %param: %.1 = param runtime_param0
  75. // CHECK:STDOUT: %if: %.1 = bind_name r#if, %param
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @A(%n.param_patt: %.1) -> %.1 {
  80. // CHECK:STDOUT: !entry:
  81. // CHECK:STDOUT: %n.ref: %.1 = name_ref n, %n
  82. // CHECK:STDOUT: return %n.ref
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: fn @B(%n.param_patt: %.1) -> %.1 {
  86. // CHECK:STDOUT: !entry:
  87. // CHECK:STDOUT: %n.ref: %.1 = name_ref n, %n
  88. // CHECK:STDOUT: return %n.ref
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: fn @C(%if.param_patt: %.1) -> %.1 {
  92. // CHECK:STDOUT: !entry:
  93. // CHECK:STDOUT: %if.ref: %.1 = name_ref r#if, %if
  94. // CHECK:STDOUT: return %if.ref
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: