Skip to content

Commit 97339a6

Browse files
committed
[ASTMangler] Use llvm::SaveAndRestore to update the CurGenericSignature
1 parent 9e89d56 commit 97339a6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,10 +2649,17 @@ void ASTMangler::appendDependentProtocolConformance(
26492649
void ASTMangler::appendConcreteProtocolConformance(
26502650
const ProtocolConformance *conformance) {
26512651
auto module = conformance->getDeclContext()->getParentModule();
2652-
if (!CurGenericSignature && conformance->getGenericSignature()) {
2653-
CurGenericSignature =
2654-
conformance->getGenericSignature()->getCanonicalSignature();
2655-
}
2652+
2653+
// It's possible that we might not have a generic signature here to get
2654+
// the conformance access path (for example, when mangling types for
2655+
// debugger). In that case, we can use the generic signature of the
2656+
// conformance (if it's present).
2657+
auto conformanceSig = conformance->getGenericSignature();
2658+
auto shouldUseConformanceSig = !CurGenericSignature && conformanceSig;
2659+
llvm::SaveAndRestore<CanGenericSignature> savedSignature(
2660+
CurGenericSignature, shouldUseConformanceSig
2661+
? conformanceSig->getCanonicalSignature()
2662+
: CurGenericSignature);
26562663

26572664
// Conforming type.
26582665
Type conformingType = conformance->getType();

0 commit comments

Comments
 (0)