local.carbon 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  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/let/local.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/local.carbon
  14. fn F(a: i32) -> i32 {
  15. let b: i32 = a;
  16. return b;
  17. }
  18. // CHECK:STDOUT: --- local.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  22. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  23. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  24. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  25. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  26. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  27. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: imports {
  31. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  32. // CHECK:STDOUT: .Int = %Core.Int
  33. // CHECK:STDOUT: import Core//prelude
  34. // CHECK:STDOUT: import Core//prelude/...
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  41. // CHECK:STDOUT: .Core = imports.%Core
  42. // CHECK:STDOUT: .F = %F.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  46. // CHECK:STDOUT: %a.patt: %pattern_type.7ce = binding_pattern a [concrete]
  47. // CHECK:STDOUT: %a.param_patt: %pattern_type.7ce = value_param_pattern %a.patt, call_param0 [concrete]
  48. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  49. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  50. // CHECK:STDOUT: } {
  51. // CHECK:STDOUT: %int_32.loc15_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  52. // CHECK:STDOUT: %i32.loc15_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  53. // CHECK:STDOUT: %a.param: %i32 = value_param call_param0
  54. // CHECK:STDOUT: %.loc15: type = splice_block %i32.loc15_9 [concrete = constants.%i32] {
  55. // CHECK:STDOUT: %int_32.loc15_9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  56. // CHECK:STDOUT: %i32.loc15_9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  59. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  60. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @F(%a.param: %i32) -> %i32 {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: name_binding_decl {
  67. // CHECK:STDOUT: %b.patt: %pattern_type.7ce = binding_pattern b [concrete]
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a
  70. // CHECK:STDOUT: %.loc16: type = splice_block %i32.loc16 [concrete = constants.%i32] {
  71. // CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  72. // CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %b: %i32 = bind_name b, %a.ref
  75. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  76. // CHECK:STDOUT: return %b.ref
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: