Files
Nicholas Bishop cf66fb8aeb roll llvm to 7024b9e1b423b3c3c6ac76ab6a73cb2c9e4ef842 (#7781)
Updated patch 0006 to include new files added in
https://github.com/llvm/llvm-project/pull/207543.

Dropped patch 0009 which was upstreamed in:
https://github.com/llvm/llvm-project/pull/190088

Minor updates to patch 0011 for changes upstream.

Minor updates in export.cpp to use `llvm::FoldingSetInsertToken` instead
of a void pointer.
2026-09-14 21:54:09 +00:00

110 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
//
// 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 !29 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @_Z1Fv(), !dbg !30
// CHECK:STDOUT: ret i32 0, !dbg !31
// 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 = !{!23}
// CHECK:STDOUT: !llvm.module.flags = !{!32, !33, !34, !6, !7}
// CHECK:STDOUT: !llvm.errno.tbaa = !{!39}
// CHECK:STDOUT:
// CHECK:STDOUT: !6 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !7 = !{i32 2, !"Debug Info Version", i32 3}
// CHECK:STDOUT: !22 = !DIFile(filename: "generic_class.carbon", directory: "")
// CHECK:STDOUT: !23 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !22, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
// CHECK:STDOUT: !24 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
// CHECK:STDOUT: !25 = !{!24}
// CHECK:STDOUT: !26 = !DISubroutineType(types: !25)
// CHECK:STDOUT: !29 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !22, line: 20, type: !26, spFlags: DISPFlagDefinition, unit: !23)
// CHECK:STDOUT: !30 = !DILocation(line: 21, column: 3, scope: !29)
// CHECK:STDOUT: !31 = !DILocation(line: 20, column: 1, scope: !29)
// CHECK:STDOUT: !32 = !{i32 8, !"PIC Level", i32 2}
// CHECK:STDOUT: !33 = !{i32 7, !"PIE Level", i32 2}
// CHECK:STDOUT: !34 = !{i32 7, !"uwtable", i32 2}
// CHECK:STDOUT: !35 = !{!"Simple C++ TBAA"}
// CHECK:STDOUT: !36 = !{!"omnipotent char", !35, i64 0}
// CHECK:STDOUT: !37 = !{!"int", !36, i64 0}
// CHECK:STDOUT: !38 = !{!"__libc_errno", !37, i64 0}
// CHECK:STDOUT: !39 = !{!38, !37, i64 0}
// CHECK:STDOUT: