Replace hardcoded special names with call into getUserfacingName()

This fixes an assertion failure when encountering previously unhandled special names.

rdar://110841130
This commit is contained in:
Adrian Prantl
2023-06-15 13:19:28 -07:00
parent 71432032d4
commit 229ad8ba84
2 changed files with 15 additions and 7 deletions

View File

@@ -569,14 +569,8 @@ private:
if (FuncDecl *FD = L.getAsASTNode<FuncDecl>())
return getName(*FD);
if (L.isASTNode<ConstructorDecl>())
return "init";
if (L.isASTNode<DestructorDecl>())
return "deinit";
if (ValueDecl *D = L.getAsASTNode<ValueDecl>())
return D->getBaseIdentifier().str();
return D->getBaseName().userFacingName();
if (auto *D = L.getAsASTNode<MacroExpansionDecl>())
return D->getMacroName().getBaseIdentifier().str();

View File

@@ -0,0 +1,14 @@
// RUN: %target-swift-frontend %s -Onone -emit-ir -g -o - -parse-as-library -module-name a | %FileCheck %s
public protocol P {}
public class C : P {}
public struct S {}
public extension S {
subscript<T>(_ val: T, _ type : T.Type = T.self) -> T? { return nil }
}
public func f() {
S()[0]
}
// CHECK: !DISubprogram(name: "deinit"
// CHECK: !DISubprogram(name: "init"
// CHECK: !DISubprogram(name: "subscript