Skip to content

Commit 1f7a5f4

Browse files
authored
Fixing /IDE/crashers/016-swift-mangle-mangler-mangleidentifier.swift (#6079)
1 parent 1570f8e commit 1f7a5f4

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

lib/AST/Mangle.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ void Mangler::mangleEntity(const ValueDecl *decl,
15921592
unsigned uncurryLevel) {
15931593
assert(!isa<ConstructorDecl>(decl));
15941594
assert(!isa<DestructorDecl>(decl));
1595-
1595+
15961596
// entity ::= static? entity-kind context entity-name
15971597
if (decl->isStatic())
15981598
Buffer << 'Z';
@@ -1605,7 +1605,12 @@ void Mangler::mangleEntity(const ValueDecl *decl,
16051605
return mangleAccessorEntity(accessorKind, func->getAddressorKind(),
16061606
func->getAccessorStorageDecl());
16071607
}
1608-
1608+
1609+
// Avoid mangling nameless entity. This may happen in erroneous code as code
1610+
// completion.
1611+
if (!decl->hasName())
1612+
return;
1613+
16091614
if (isa<VarDecl>(decl)) {
16101615
Buffer << 'v';
16111616
} else if (isa<SubscriptDecl>(decl)) {

validation-test/IDE/crashers/016-swift-mangle-mangler-mangleidentifier.swift

Lines changed: 0 additions & 3 deletions
This file was deleted.

validation-test/IDE/crashers/100-swift-mangle-mangler-mangledeclname.swift

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
// REQUIRES: asserts
3+
var d{let:{func a#^A^#
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
{let:{class S(}#^A^#

0 commit comments

Comments
 (0)