char.carbon 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/full.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/builtins/char.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/builtins/char.carbon
  12. // --- basic.carbon
  13. library "[[@TEST_NAME]]";
  14. fn Example() -> char {
  15. var c: char = 'a';
  16. return c;
  17. }
  18. // CHECK:STDOUT: ; ModuleID = 'basic.carbon'
  19. // CHECK:STDOUT: source_filename = "basic.carbon"
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: ; Function Attrs: nounwind
  22. // CHECK:STDOUT: define i8 @_CExample.Main() #0 !dbg !4 {
  23. // CHECK:STDOUT: entry:
  24. // CHECK:STDOUT: %c.var = alloca i8, align 1, !dbg !8
  25. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !8
  26. // CHECK:STDOUT: store i8 97, ptr %c.var, align 1, !dbg !8
  27. // CHECK:STDOUT: %.loc6 = load i8, ptr %c.var, align 1, !dbg !9
  28. // CHECK:STDOUT: call void @"_COp.e440520c1277b33b:core.Destroy.Core"(ptr %c.var), !dbg !8
  29. // CHECK:STDOUT: ret i8 %.loc6, !dbg !10
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: ; Function Attrs: nounwind
  33. // CHECK:STDOUT: define weak_odr void @"_COp.e440520c1277b33b:core.Destroy.Core"(ptr %self) #0 !dbg !11 {
  34. // CHECK:STDOUT: entry:
  35. // CHECK:STDOUT: ret void, !dbg !16
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  39. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: attributes #0 = { nounwind }
  42. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  45. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  48. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  49. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  50. // CHECK:STDOUT: !3 = !DIFile(filename: "basic.carbon", directory: "")
  51. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Example", linkageName: "_CExample.Main", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  52. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  53. // CHECK:STDOUT: !6 = !{!7}
  54. // CHECK:STDOUT: !7 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_unsigned)
  55. // CHECK:STDOUT: !8 = !DILocation(line: 5, column: 3, scope: !4)
  56. // CHECK:STDOUT: !9 = !DILocation(line: 6, column: 10, scope: !4)
  57. // CHECK:STDOUT: !10 = !DILocation(line: 6, column: 3, scope: !4)
  58. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "Op", linkageName: "_COp.e440520c1277b33b:core.Destroy.Core", scope: null, file: !3, line: 5, type: !12, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !14)
  59. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  60. // CHECK:STDOUT: !13 = !{null, !7}
  61. // CHECK:STDOUT: !14 = !{!15}
  62. // CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !11, type: !7)
  63. // CHECK:STDOUT: !16 = !DILocation(line: 5, column: 3, scope: !11)