mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 10:31:03 +01:00
Fix name mangling of generic impls (#6533)
### Description Mangling collisions occur when implementing interfaces with generic parameters. The mangler does not use the specific id, causing the same symbol `_C[FunctionName].[PackageName]:[InterfaceName].[PackageName]` to be generated for all of the implementations below: ```carbon // Generic interface parameters ignored impl C as I(A) impl C as I(B) // Generic class parameters ignored impl D(A) as I impl D(B) as I // Both ignored impl D(A) as I(A) impl D(B) as I(B) ``` ### Changes Updated the mangling logic for `SemIR::ClassDecl` and `SemIR::InterfaceDecl` to include the specific id. Now the mangling ensures unique symbols for generic implementations using the format: `_C[FunctionName].[FunctionSpecificId].[PackageName]:[InterfaceName].[InterfaceSpecificId].[PackageName]`. Closes #6498
This commit is contained in:
@@ -47,7 +47,7 @@ fn G() {
|
||||
// CHECK:STDOUT: source_filename = "call_impl_function.carbon"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define i32 @"_CF.ImplsSomeInterface.Main:SomeInterface.Main"(i32 %x) #0 !dbg !4 {
|
||||
// CHECK:STDOUT: define i32 @"_CF.ImplsSomeInterface.Main:SomeInterface.b88d1103f417c6d4.Main"(i32 %x) #0 !dbg !4 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %Int.as.Negate.impl.Op.call = sub i32 0, %x, !dbg !10
|
||||
// CHECK:STDOUT: ret i32 %Int.as.Negate.impl.Op.call, !dbg !11
|
||||
@@ -63,7 +63,7 @@ fn G() {
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr i32 @_CCallGenericMethod.Main.416a86e385b6ba35(i32 %x) #0 !dbg !17 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %SomeInterface.F.call = call i32 @"_CF.ImplsSomeInterface.Main:SomeInterface.Main"(i32 %x), !dbg !20
|
||||
// CHECK:STDOUT: %SomeInterface.F.call = call i32 @"_CF.ImplsSomeInterface.Main:SomeInterface.b88d1103f417c6d4.Main"(i32 %x), !dbg !20
|
||||
// CHECK:STDOUT: ret i32 %SomeInterface.F.call, !dbg !21
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -76,7 +76,7 @@ fn G() {
|
||||
// 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: "call_impl_function.carbon", directory: "")
|
||||
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.ImplsSomeInterface.Main:SomeInterface.Main", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
|
||||
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.ImplsSomeInterface.Main:SomeInterface.b88d1103f417c6d4.Main", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8)
|
||||
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
|
||||
// CHECK:STDOUT: !6 = !{!7, !7}
|
||||
// CHECK:STDOUT: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
|
||||
Reference in New Issue
Block a user