raw_identifier.carbon 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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: %.loc15_10.1: %.1 = tuple_literal ()
  43. // CHECK:STDOUT: %.loc15_10.2: type = converted %.loc15_10.1, constants.%.1 [template = constants.%.1]
  44. // CHECK:STDOUT: %n.loc15_6.1: %.1 = param n
  45. // CHECK:STDOUT: @A.%n: %.1 = bind_name n, %n.loc15_6.1
  46. // CHECK:STDOUT: %.loc15_17.1: %.1 = tuple_literal ()
  47. // CHECK:STDOUT: %.loc15_17.2: type = converted %.loc15_17.1, constants.%.1 [template = constants.%.1]
  48. // CHECK:STDOUT: @A.%return: ref %.1 = var <return slot>
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  51. // CHECK:STDOUT: %.loc19_12.1: %.1 = tuple_literal ()
  52. // CHECK:STDOUT: %.loc19_12.2: type = converted %.loc19_12.1, constants.%.1 [template = constants.%.1]
  53. // CHECK:STDOUT: %n.loc19_6.1: %.1 = param n
  54. // CHECK:STDOUT: @B.%n: %.1 = bind_name n, %n.loc19_6.1
  55. // CHECK:STDOUT: %.loc19_19.1: %.1 = tuple_literal ()
  56. // CHECK:STDOUT: %.loc19_19.2: type = converted %.loc19_19.1, constants.%.1 [template = constants.%.1]
  57. // CHECK:STDOUT: @B.%return: ref %.1 = var <return slot>
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  60. // CHECK:STDOUT: %.loc23_13.1: %.1 = tuple_literal ()
  61. // CHECK:STDOUT: %.loc23_13.2: type = converted %.loc23_13.1, constants.%.1 [template = constants.%.1]
  62. // CHECK:STDOUT: %if.loc23_6.1: %.1 = param r#if
  63. // CHECK:STDOUT: @C.%if: %.1 = bind_name r#if, %if.loc23_6.1
  64. // CHECK:STDOUT: %.loc23_20.1: %.1 = tuple_literal ()
  65. // CHECK:STDOUT: %.loc23_20.2: type = converted %.loc23_20.1, constants.%.1 [template = constants.%.1]
  66. // CHECK:STDOUT: @C.%return: ref %.1 = var <return slot>
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn @A(%n: %.1) -> %.1 {
  71. // CHECK:STDOUT: !entry:
  72. // CHECK:STDOUT: %n.ref: %.1 = name_ref n, %n
  73. // CHECK:STDOUT: return %n.ref
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @B(%n: %.1) -> %.1 {
  77. // CHECK:STDOUT: !entry:
  78. // CHECK:STDOUT: %n.ref: %.1 = name_ref n, %n
  79. // CHECK:STDOUT: return %n.ref
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @C(%if: %.1) -> %.1 {
  83. // CHECK:STDOUT: !entry:
  84. // CHECK:STDOUT: %if.ref: %.1 = name_ref r#if, %if
  85. // CHECK:STDOUT: return %if.ref
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT: