Files
carbon-lang/toolchain/driver/testdata/stdin.carbon
T
Richard Smith a6061d975c Compute type layouts in SemIR / Check (#7066)
Instead of allowing lower to pick whatever type layout it desires,
compute the layouts of types as part of completing the type, and make
lower build types that match that representation.

For now we assume that all pointers are 64-bit, since we don't have
access to target information. We allow tail padding reuse for structs
and tuple types (and by extension, for classes, since they use structs
as their object representation), but not for arrays.

In order to build matching LLVM types, we create LLVM packed structs
where necessary, and we insert inter-field padding on the end of the
previous field so that GEP indexes still always match Carbon's
ElementIndexes.

We don't yet use the computed alignment much in LLVM IR generation -- in
particular, `alloca`s, `load`s, and `store`s should probably use the
computed type alignment, but don't.

Assisted-by: Gemini via Antigravity
2026-04-16 22:37:48 +00:00

109 lines
4.9 KiB
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This is checking that the stdin filename is handled consistently across
// dump flags.
// TODO: Align lex/parse with check/lower.
//
// ARGS: compile - --phase=lower --no-prelude-import --target=x86_64-linux-gnu --dump-tokens --dump-parse-tree --dump-sem-ir --dump-raw-sem-ir --dump-llvm-ir
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/stdin.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/stdin.carbon
// CHECK:STDOUT: - filename: <stdin>
// CHECK:STDOUT: tokens:
// CHECK:STDOUT: - { index: 0, kind: "FileStart", line: 1, column: 1, indent: 1, spelling: "" }
// CHECK:STDOUT: - { index: 1, kind: "FileEnd", line: 1, column: 1, indent: 1, spelling: "", has_leading_space: true }
// CHECK:STDOUT: - filename: <stdin>
// CHECK:STDOUT: parse_tree: [
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDOUT: ---
// CHECK:STDOUT: filename: '-'
// CHECK:STDOUT: sem_ir:
// CHECK:STDOUT: names: {}
// CHECK:STDOUT: import_irs:
// CHECK:STDOUT: 'import_ir(ApiForImpl)': {decl_id: inst<none>, is_export: false}
// CHECK:STDOUT: 'import_ir(Cpp)': {decl_id: inst<none>, is_export: false}
// CHECK:STDOUT: import_ir_insts: {}
// CHECK:STDOUT: clang_decls: {}
// CHECK:STDOUT: name_scopes:
// CHECK:STDOUT: name_scope0: {inst: instF, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {}}
// CHECK:STDOUT: entity_names: {}
// CHECK:STDOUT: cpp_global_vars: {}
// CHECK:STDOUT: functions: {}
// CHECK:STDOUT: classes: {}
// CHECK:STDOUT: interfaces: {}
// CHECK:STDOUT: associated_constants: {}
// CHECK:STDOUT: impls: {}
// CHECK:STDOUT: generics: {}
// CHECK:STDOUT: specifics: {}
// CHECK:STDOUT: specific_interfaces: {}
// CHECK:STDOUT: struct_type_fields:
// CHECK:STDOUT: struct_type_fields_empty: {}
// CHECK:STDOUT: types:
// CHECK:STDOUT: 'type(TypeType)':
// CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
// CHECK:STDOUT: object_layout:
// CHECK:STDOUT: size: 0
// CHECK:STDOUT: alignment: 1
// CHECK:STDOUT: 'type(inst(FormType))':
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(FormType))}
// CHECK:STDOUT: object_layout:
// CHECK:STDOUT: size: 0
// CHECK:STDOUT: alignment: 1
// CHECK:STDOUT: 'type(Error)':
// CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
// CHECK:STDOUT: object_layout:
// CHECK:STDOUT: size: 0
// CHECK:STDOUT: alignment: 1
// CHECK:STDOUT: 'type(inst(NamespaceType))':
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
// CHECK:STDOUT: object_layout:
// CHECK:STDOUT: size: 0
// CHECK:STDOUT: alignment: 1
// CHECK:STDOUT: facet_types: {}
// CHECK:STDOUT: insts:
// CHECK:STDOUT: instF: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
// CHECK:STDOUT: constant_values:
// CHECK:STDOUT: values:
// CHECK:STDOUT: instF: concrete_constant(instF)
// CHECK:STDOUT: symbolic_constants: {}
// CHECK:STDOUT: inst_blocks:
// CHECK:STDOUT: inst_block_empty: {}
// CHECK:STDOUT: exports: {}
// CHECK:STDOUT: generated: {}
// CHECK:STDOUT: imports: {}
// CHECK:STDOUT: global_init: {}
// CHECK:STDOUT: inst_block60000005:
// CHECK:STDOUT: 0: instF
// CHECK:STDOUT: value_stores:
// CHECK:STDOUT: shared_values:
// CHECK:STDOUT: ints: {}
// CHECK:STDOUT: reals: {}
// CHECK:STDOUT: floats: {}
// CHECK:STDOUT: identifiers: {}
// CHECK:STDOUT: strings: {}
// CHECK:STDOUT: ...
// CHECK:STDOUT: --- -
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; ModuleID = '-'
// CHECK:STDOUT: source_filename = "-"
// CHECK:STDOUT:
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
// CHECK:STDOUT: !llvm.dbg.cu = !{!2}
// CHECK:STDOUT:
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !3 = !DIFile(filename: "-", directory: "")