function.carbon 3.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/convert.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/namespace/function.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/function.carbon
  14. namespace Foo;
  15. // Never called, just here to help catch bugs in name lookup.
  16. fn Baz() {
  17. }
  18. fn Foo.Baz() {
  19. }
  20. fn Bar() {
  21. Foo.Baz();
  22. }
  23. // CHECK:STDOUT: --- function.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %Baz.type.03f: type = fn_type @Baz.1 [concrete]
  27. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  28. // CHECK:STDOUT: %Baz.5ea: %Baz.type.03f = struct_value () [concrete]
  29. // CHECK:STDOUT: %Baz.type.898: type = fn_type @Baz.2 [concrete]
  30. // CHECK:STDOUT: %Baz.eb4: %Baz.type.898 = struct_value () [concrete]
  31. // CHECK:STDOUT: %Bar.type: type = fn_type @Bar [concrete]
  32. // CHECK:STDOUT: %Bar: %Bar.type = struct_value () [concrete]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: imports {
  36. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/...
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  44. // CHECK:STDOUT: .Core = imports.%Core
  45. // CHECK:STDOUT: .Foo = %Foo
  46. // CHECK:STDOUT: .Baz = %Baz.decl.loc18
  47. // CHECK:STDOUT: .Bar = %Bar.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %Foo: <namespace> = namespace [concrete] {
  51. // CHECK:STDOUT: .Baz = %Baz.decl.loc21
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Baz.decl.loc18: %Baz.type.03f = fn_decl @Baz.1 [concrete = constants.%Baz.5ea] {} {}
  54. // CHECK:STDOUT: %Baz.decl.loc21: %Baz.type.898 = fn_decl @Baz.2 [concrete = constants.%Baz.eb4] {} {}
  55. // CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [concrete = constants.%Bar] {} {}
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Baz.1() {
  59. // CHECK:STDOUT: !entry:
  60. // CHECK:STDOUT: return
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: fn @Baz.2() {
  64. // CHECK:STDOUT: !entry:
  65. // CHECK:STDOUT: return
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @Bar() {
  69. // CHECK:STDOUT: !entry:
  70. // CHECK:STDOUT: %Foo.ref: <namespace> = name_ref Foo, file.%Foo [concrete = file.%Foo]
  71. // CHECK:STDOUT: %Baz.ref: %Baz.type.898 = name_ref Baz, file.%Baz.decl.loc21 [concrete = constants.%Baz.eb4]
  72. // CHECK:STDOUT: %Baz.call: init %empty_tuple.type = call %Baz.ref()
  73. // CHECK:STDOUT: return
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: