/
githubmirror
/
carbon-lang
Обзор
Документация
Войти
/
githubmirror
/
carbon-lang
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
toolchain/lower/testdata/interop/cpp/class/export/generic.carbon
109 строк
5 KB
Nicholas Bishop
Add initial support for exporting generic classes (#7595)
10 авг 2026, 20:47
Не верифицирован
10 авг 2026, 20:47
de1cd70
Код
Авторство
О чём код?
// 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 // // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/interop/cpp/class/export/generic.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/class/export/generic.carbon // --- generic_class.carbon library "[[@TEST_NAME]]"; import Cpp; class C(T: type) { var t: T; } inline Cpp ''' class A {}; class B {}; void F() { Carbon::C<A> c1; c1.t = A(); Carbon::C<B> c2; c2.t = B(); } '''; fn Run() { Cpp.F(); } // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'generic_class.carbon' // CHECK:STDOUT: source_filename = "generic_class.carbon" // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: // CHECK:STDOUT: %"class.Carbon::C" = type {} // CHECK:STDOUT: %class.A = type { i8 } // CHECK:STDOUT: %"class.Carbon::C.0" = type {} // CHECK:STDOUT: %class.B = type { i8 } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable // CHECK:STDOUT: define dso_local void @_Z1Fv() #0 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %c1 = alloca %"class.Carbon::C", align 1 // CHECK:STDOUT: %ref.tmp = alloca %class.A, align 1 // CHECK:STDOUT: %c2 = alloca %"class.Carbon::C.0", align 1 // CHECK:STDOUT: %ref.tmp1 = alloca %class.B, align 1 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c1) #2 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp) #2 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp) #2 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c2) #2 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp1) #2 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp1) #2 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %c2) #2 // CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %c1) #2 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) // CHECK:STDOUT: declare void @llvm.lifetime.end.p0(ptr captures(none)) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define i32 @main() #2 !dbg !12 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_Z1Fv(), !dbg !16 // CHECK:STDOUT: ret i32 0, !dbg !17 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 3, 2, 1, 0 } // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.end.p0, { 3, 2, 1, 0 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: attributes #2 = { nounwind } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!0} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3, !4, !5, !6} // CHECK:STDOUT: !llvm.errno.tbaa = !{!7} // CHECK:STDOUT: // CHECK:STDOUT: !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !1 = !DIFile(filename: "generic_class.carbon", directory: "") // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !5 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !6 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !7 = !{!8, !9, i64 0} // CHECK:STDOUT: !8 = !{!"__libc_errno", !9, i64 0} // CHECK:STDOUT: !9 = !{!"int", !10, i64 0} // CHECK:STDOUT: !10 = !{!"omnipotent char", !11, i64 0} // CHECK:STDOUT: !11 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !1, line: 20, type: !13, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !13 = !DISubroutineType(types: !14) // CHECK:STDOUT: !14 = !{!15} // CHECK:STDOUT: !15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) // CHECK:STDOUT: !16 = !DILocation(line: 21, column: 3, scope: !12) // CHECK:STDOUT: !17 = !DILocation(line: 20, column: 1, scope: !12) // CHECK:STDOUT: