mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +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:
@@ -114,7 +114,7 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) {
|
||||
// CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16)
|
||||
// CHECK:STDOUT: !23 = !DILocation(line: 19, column: 5, scope: !16)
|
||||
// CHECK:STDOUT: !24 = !DILocation(line: 275, column: 3, scope: !25, inlinedAt: !32)
|
||||
// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk.Int.Core:AddAssignWith.Core.75bec4d236c9daa5", scope: null, file: !26, line: 275, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29)
|
||||
// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk.Int.9452f4c51951679b.Core:AddAssignWith.5375cfcbca6d9e35.Core.75bec4d236c9daa5", scope: null, file: !26, line: 275, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29)
|
||||
// CHECK:STDOUT: !26 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "")
|
||||
// CHECK:STDOUT: !27 = !DISubroutineType(types: !28)
|
||||
// CHECK:STDOUT: !28 = !{null, !7, !7}
|
||||
@@ -122,7 +122,7 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) {
|
||||
// CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !25, type: !7)
|
||||
// CHECK:STDOUT: !31 = !DILocalVariable(arg: 2, scope: !25, type: !7)
|
||||
// CHECK:STDOUT: !32 = distinct !DILocation(line: 341, column: 5, scope: !33, inlinedAt: !38)
|
||||
// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 339, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36)
|
||||
// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 339, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36)
|
||||
// CHECK:STDOUT: !34 = !DISubroutineType(types: !35)
|
||||
// CHECK:STDOUT: !35 = !{null, !7}
|
||||
// CHECK:STDOUT: !36 = !{!37}
|
||||
|
||||
Reference in New Issue
Block a user