Skip to content

Commit 8c6fe1c

Browse files
authored
fix #61531 swift-symbolgraph-extract crashes when trying to emit the 'Swift' module (#62825)
fix a crash in symbol graph generation caused by an empty SmallVector access while expanding protocol compositions during conformance expansion for extension block symbols rdar://103322385
1 parent 902f023 commit 8c6fe1c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

lib/SymbolGraphGen/SymbolGraphASTWalker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
214214
llvm_unreachable("Expected ProtocolDecl or ProtocolCompositionType");
215215
}
216216

217-
while (const auto *Comp = UnexpandedCompositions.pop_back_val()) {
217+
while (!UnexpandedCompositions.empty()) {
218+
const auto *Comp = UnexpandedCompositions.pop_back_val();
218219
for (const auto &Member : Comp->getMembers()) {
219220
if (const auto *Proto =
220221
dyn_cast_or_null<ProtocolDecl>(Member->getAnyNominal())) {

test/SymbolGraph/Relationships/ConformsTo/Indirect.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ extension ES: EQ {
3535
// EQ : EP
3636
// EXTERNAL-DAG: "kind": "conformsTo",{{[[:space:]]*}}"source": "s:16ExternalIndirect2EQP",{{[[:space:]]*}}"target": "s:16ExternalIndirect2EPP"
3737

38+
// extension ES : EA (originating from EP : EAB and typealias EAB = EA & EB)
39+
// EXTENSION-DAG: "kind": "conformsTo",{{[[:space:]]*}}"source": "s:e:s:16ExternalIndirect2ESV0B0E3fooyyF",{{[[:space:]]*}}"target": "s:16ExternalIndirect2EAP"
40+
41+
// extension ES : EB (originating from EP : EAB and typealias EAB = EA & EB)
42+
// EXTENSION-DAG: "kind": "conformsTo",{{[[:space:]]*}}"source": "s:e:s:16ExternalIndirect2ESV0B0E3fooyyF",{{[[:space:]]*}}"target": "s:16ExternalIndirect2EBP"
43+
3844
// extension ES : EP
3945
// EXTENSION-DAG: "kind": "conformsTo",{{[[:space:]]*}}"source": "s:e:s:16ExternalIndirect2ESV0B0E3fooyyF",{{[[:space:]]*}}"target": "s:16ExternalIndirect2EPP"
4046

test/SymbolGraph/Relationships/ConformsTo/Inputs/ExternalIndirect.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
public protocol EP {
1+
public protocol EA {}
2+
public protocol EB {}
3+
4+
public typealias EAB = EA & EB
5+
6+
public protocol EP : EAB {
27
func foo()
38
}
49

0 commit comments

Comments
 (0)