mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Implement unused pattern bindings, continued (#6518)
Implementation of unused pattern bindings #2022, continued. Whereas previous PR #6460 took care of parsing, and PR #6479 prepared the stage by using _ in some test cases, this PR has the the actual implementation, using a simple dataflow analysis. --------- Co-authored-by: Burak Emir <bqe@google.com> Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
co-authored by
Burak Emir
jonmeow
parent
bea24a8bee
commit
fdb188ccfd
+14
-14
@@ -45,21 +45,21 @@ interface I(T:! type) {
|
||||
}
|
||||
|
||||
impl C as I(A) {
|
||||
fn F[self: C]() -> A { return {}; }
|
||||
fn F[unused self: C]() -> A { return {}; }
|
||||
}
|
||||
|
||||
impl C as I(B) {
|
||||
fn F[self: C]() -> B { return {}; }
|
||||
fn F[unused self: C]() -> B { return {}; }
|
||||
}
|
||||
|
||||
fn F1(x: C, y: C) {
|
||||
var a: A = x.(I(A).F)();
|
||||
var b: B = y.(I(B).F)();
|
||||
var unused a: A = x.(I(A).F)();
|
||||
var unused b: B = y.(I(B).F)();
|
||||
}
|
||||
|
||||
fn F2[T:! I(A), U:! I(B)](x: T, y: U) {
|
||||
var a: A = x.F();
|
||||
var b: B = y.F();
|
||||
var unused a: A = x.F();
|
||||
var unused b: B = y.F();
|
||||
}
|
||||
|
||||
// --- generic_class_impls.carbon
|
||||
@@ -127,20 +127,20 @@ impl C(B) as I {
|
||||
// CHECK:STDOUT: ; ModuleID = 'generic_impls.carbon'
|
||||
// CHECK:STDOUT: source_filename = "generic_impls.carbon"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: @A.val.loc13_35 = internal constant {} zeroinitializer
|
||||
// CHECK:STDOUT: @B.val.loc17_35 = internal constant {} zeroinitializer
|
||||
// CHECK:STDOUT: @A.val.loc13_42 = internal constant {} zeroinitializer
|
||||
// CHECK:STDOUT: @B.val.loc17_42 = internal constant {} zeroinitializer
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @"_CF.C.Main:I.96947bccc1c5e61b.Main"(ptr sret({}) %return, ptr %self) #0 !dbg !4 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @A.val.loc13_35, i64 0, i1 false), !dbg !10
|
||||
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @A.val.loc13_42, i64 0, i1 false), !dbg !10
|
||||
// CHECK:STDOUT: ret void, !dbg !10
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @"_CF.C.Main:I.707dbe5ae2414d29.Main"(ptr sret({}) %return, ptr %self) #0 !dbg !11 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @B.val.loc17_35, i64 0, i1 false), !dbg !14
|
||||
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %return, ptr align 1 @B.val.loc17_42, i64 0, i1 false), !dbg !14
|
||||
// CHECK:STDOUT: ret void, !dbg !14
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -183,11 +183,11 @@ impl C(B) as I {
|
||||
// CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
|
||||
// CHECK:STDOUT: !8 = !{!9}
|
||||
// CHECK:STDOUT: !9 = !DILocalVariable(arg: 1, scope: !4, type: !7)
|
||||
// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 26, scope: !4)
|
||||
// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 33, scope: !4)
|
||||
// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "F", linkageName: "_CF.C.Main:I.707dbe5ae2414d29.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !12)
|
||||
// CHECK:STDOUT: !12 = !{!13}
|
||||
// CHECK:STDOUT: !13 = !DILocalVariable(arg: 1, scope: !11, type: !7)
|
||||
// CHECK:STDOUT: !14 = !DILocation(line: 17, column: 26, scope: !11)
|
||||
// CHECK:STDOUT: !14 = !DILocation(line: 17, column: 33, scope: !11)
|
||||
// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "F1", linkageName: "_CF1.Main", scope: null, file: !3, line: 20, type: !16, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !18)
|
||||
// CHECK:STDOUT: !16 = !DISubroutineType(types: !17)
|
||||
// CHECK:STDOUT: !17 = !{null, !7, !7}
|
||||
@@ -196,8 +196,8 @@ impl C(B) as I {
|
||||
// CHECK:STDOUT: !20 = !DILocalVariable(arg: 2, scope: !15, type: !7)
|
||||
// CHECK:STDOUT: !21 = !DILocation(line: 21, column: 3, scope: !15)
|
||||
// CHECK:STDOUT: !22 = !DILocation(line: 22, column: 3, scope: !15)
|
||||
// CHECK:STDOUT: !23 = !DILocation(line: 21, column: 14, scope: !15)
|
||||
// CHECK:STDOUT: !24 = !DILocation(line: 22, column: 14, scope: !15)
|
||||
// CHECK:STDOUT: !23 = !DILocation(line: 21, column: 21, scope: !15)
|
||||
// CHECK:STDOUT: !24 = !DILocation(line: 22, column: 21, scope: !15)
|
||||
// CHECK:STDOUT: !25 = !DILocation(line: 20, column: 1, scope: !15)
|
||||
// CHECK:STDOUT: ; ModuleID = 'generic_class_impls.carbon'
|
||||
// CHECK:STDOUT: source_filename = "generic_class_impls.carbon"
|
||||
|
||||
Reference in New Issue
Block a user