mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 19:55:11 +00:00
Adds a patch to adjust for libc build changes. Removes patch 13 which landed upstream. Modifies patch 12 to apply successfully. Removes an unused variable in testing caught during testing.
111 lines
5.0 KiB
Plaintext
111 lines
5.0 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::Main::C" = type {}
|
|
// CHECK:STDOUT: %class.A = type { i8 }
|
|
// CHECK:STDOUT: %"class.Carbon::Main::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::Main::C", align 1
|
|
// CHECK:STDOUT: %ref.tmp = alloca %class.A, align 1
|
|
// CHECK:STDOUT: %c2 = alloca %"class.Carbon::Main::C.0", align 1
|
|
// CHECK:STDOUT: %ref.tmp1 = alloca %class.B, align 1
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c1)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c2)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %ref.tmp1)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %ref.tmp1)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %c2)
|
|
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %c1)
|
|
// 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, !35, !6, !7}
|
|
// CHECK:STDOUT: !llvm.errno.tbaa = !{!40}
|
|
// 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 2, !"debugger-tuning", !"gdb"}
|
|
// CHECK:STDOUT: !33 = !{i32 8, !"PIC Level", i32 2}
|
|
// CHECK:STDOUT: !34 = !{i32 7, !"PIE Level", i32 2}
|
|
// CHECK:STDOUT: !35 = !{i32 7, !"uwtable", i32 2}
|
|
// CHECK:STDOUT: !36 = !{!"Simple C++ TBAA"}
|
|
// CHECK:STDOUT: !37 = !{!"omnipotent char", !36, i64 0}
|
|
// CHECK:STDOUT: !38 = !{!"int", !37, i64 0}
|
|
// CHECK:STDOUT: !39 = !{!"__libc_errno", !38, i64 0}
|
|
// CHECK:STDOUT: !40 = !{!39, !38, i64 0}
|
|
// CHECK:STDOUT:
|