Skip to content

Commit 7d082ab

Browse files
authored
[ASTMangler] Don't verify the USR mangling for invalid storage decls (#32459)
1 parent b61b68d commit 7d082ab

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,10 @@ std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind,
677677
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
678678
Buffer << USRPrefix;
679679
appendAccessorEntity(getCodeForAccessorKind(kind), decl, isStatic);
680-
// We have a custom prefix, so finalize() won't verify for us. Do it manually.
681-
verify(Storage.str().drop_front(USRPrefix.size()));
680+
// We have a custom prefix, so finalize() won't verify for us. If we're not
681+
// in invalid code (coming from an IDE caller) verify manually.
682+
if (!decl->isInvalid())
683+
verify(Storage.str().drop_front(USRPrefix.size()));
682684
return finalize();
683685
}
684686

test/SourceKit/CursorInfo/cursor_invalid.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ func resyncParser2() {}
2424

2525
Swift(label: 3)
2626

27-
enum Outer {
28-
case Inner(IDontExist)
27+
enum Outer1 {
28+
case Inner1(IDontExist)
29+
}
30+
31+
enum Outer2 {
32+
case Inner2(x: Undefined)
2933
}
3034

3135
// RUN: %sourcekitd-test -req=cursor -pos=4:13 %s -- %s | %FileCheck -check-prefix=CHECK1 %s
@@ -68,6 +72,10 @@ enum Outer {
6872

6973
// RUN: %sourcekitd-test -req=cursor -pos=25:7 %s -- %s | %FileCheck -check-prefix=DIAG %s
7074

71-
// RUN: %sourcekitd-test -req=cursor -pos=28:8 %s -- %s | %FileCheck -check-prefix=INVALID_ENUM %s
72-
// INVALID_ENUM: source.lang.swift.decl.enumelement (28:8-28:13)
73-
// INVALID_ENUM: Inner(_:)
75+
// RUN: %sourcekitd-test -req=cursor -pos=28:8 %s -- %s | %FileCheck -check-prefix=INVALID_ENUM1 %s
76+
// INVALID_ENUM1: source.lang.swift.decl.enumelement (28:8-28:14)
77+
// INVALID_ENUM1: Inner1(_:)
78+
79+
// RUN: %sourcekitd-test -req=cursor -pos=32:8 %s -- %s | %FileCheck -check-prefix=INVALID_ENUM2 %s
80+
// INVALID_ENUM2: source.lang.swift.decl.enumelement (32:8-32:14)
81+
// INVALID_ENUM2: Inner2(x:)

0 commit comments

Comments
 (0)