mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IDE] Don't produce USRs for nameless parameters.
...and /do/ produce them for 'self' parameters in destructors when they /are/ named. I suspect this was the cause of the original problem.
This commit is contained in:
@@ -122,7 +122,7 @@ public:
|
||||
|
||||
std::string mangleTypeAsContextUSR(const NominalTypeDecl *type);
|
||||
|
||||
std::string mangleDeclAsUSR(ValueDecl *Decl, StringRef USRPrefix);
|
||||
std::string mangleDeclAsUSR(const ValueDecl *Decl, StringRef USRPrefix);
|
||||
|
||||
std::string mangleAccessorEntityAsUSR(AccessorKind kind,
|
||||
AddressorKind addressorKind,
|
||||
|
||||
@@ -141,7 +141,7 @@ static bool ShouldUseObjCUSR(const Decl *D) {
|
||||
}
|
||||
|
||||
bool ide::printDeclUSR(const ValueDecl *D, raw_ostream &OS) {
|
||||
if (!D->hasName() && !isa<ParamDecl>(D) &&
|
||||
if (!D->hasName() &&
|
||||
(!isa<FuncDecl>(D) ||
|
||||
cast<FuncDecl>(D)->getAccessorKind() == AccessorKind::NotAccessor))
|
||||
return true; // Ignore.
|
||||
@@ -150,8 +150,6 @@ bool ide::printDeclUSR(const ValueDecl *D, raw_ostream &OS) {
|
||||
if (isa<ModuleDecl>(D))
|
||||
return true; // Ignore.
|
||||
|
||||
ValueDecl *VD = const_cast<ValueDecl *>(D);
|
||||
|
||||
auto interpretAsClangNode = [](const ValueDecl *D)->ClangNode {
|
||||
ClangNode ClangN = D->getClangNode();
|
||||
if (auto ClangD = ClangN.getAsDecl()) {
|
||||
@@ -204,8 +202,8 @@ bool ide::printDeclUSR(const ValueDecl *D, raw_ostream &OS) {
|
||||
return Ignore;
|
||||
}
|
||||
|
||||
if (ShouldUseObjCUSR(VD)) {
|
||||
return printObjCUSR(VD, OS);
|
||||
if (ShouldUseObjCUSR(D)) {
|
||||
return printObjCUSR(D, OS);
|
||||
}
|
||||
|
||||
if (!D->hasInterfaceType())
|
||||
@@ -217,12 +215,8 @@ bool ide::printDeclUSR(const ValueDecl *D, raw_ostream &OS) {
|
||||
}))
|
||||
return true;
|
||||
|
||||
// FIXME: mangling 'self' in destructors crashes in mangler.
|
||||
if (isa<ParamDecl>(VD) && isa<DestructorDecl>(VD->getDeclContext()))
|
||||
return true;
|
||||
|
||||
Mangle::ASTMangler NewMangler;
|
||||
std::string Mangled = NewMangler.mangleDeclAsUSR(VD, getUSRSpacePrefix());
|
||||
std::string Mangled = NewMangler.mangleDeclAsUSR(D, getUSRSpacePrefix());
|
||||
|
||||
OS << Mangled;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class GenericClass {
|
||||
// CHECK: [[@LINE+1]]:3 s:14swift_ide_test12GenericClassCfd{{$}}
|
||||
deinit {
|
||||
// CHECK: [[@LINE+2]]:18 s:14swift_ide_test12GenericClassC9classFuncyACFZ{{$}}
|
||||
// CHECK: [[@LINE+1]]:28 ERROR:no-usr{{$}}
|
||||
// CHECK: [[@LINE+1]]:28 s:14swift_ide_test12GenericClassCfd4selfL_ACv{{$}}
|
||||
GenericClass.classFunc(self)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ class AClass {
|
||||
// CHECK-NEXT: RelChild | instance-method/Swift | instanceMethod(a:b:_:d:_:) | s:14swift_ide_test6AClassC14instanceMethodySi1a_Si1bS2i1dSitF
|
||||
// CHECK: [[@LINE-5]]:33 | param(local)/Swift | b | s:{{.*}} | Def,RelChild | rel: 1
|
||||
// CHECK: [[@LINE-6]]:43 | param(local)/Swift | c | s:{{.*}} | Def,RelChild | rel: 1
|
||||
// CHECK: [[@LINE-7]]:53 | param(local)/Swift | _ | s:{{.*}} | Def,RelChild | rel: 1
|
||||
// CHECK: [[@LINE-8]]:61 | param/Swift | _ | s:{{.*}} | Def,RelChild | rel: 1
|
||||
// CHECK-NOT: {{^}}[[@LINE-7]]:53 |
|
||||
// CHECK-NOT: {{^}}[[@LINE-8]]:61 |
|
||||
|
||||
_ = a
|
||||
// CHECK: [[@LINE-1]]:9 | param/Swift | a | s:{{.*}} | Ref,Read,RelCont | rel: 1
|
||||
|
||||
Reference in New Issue
Block a user