[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:
Jordan Rose
2017-04-14 13:59:15 -07:00
parent 7c73ba5fe3
commit 5c80f1edaf
4 changed files with 8 additions and 14 deletions

View File

@@ -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,

View File

@@ -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;

View File

@@ -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)
}

View File

@@ -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