Skip to content

Commit 7883dc2

Browse files
committed
[SIL Printer] Make SILSpecializeAttr printing defensive
1 parent 8c2707c commit 7883dc2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/SIL/SILPrinter.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,8 +3033,17 @@ void SILSpecializeAttr::print(llvm::raw_ostream &OS) const {
30333033
OS << "exported: " << exported << ", ";
30343034
OS << "kind: " << kind << ", ";
30353035

3036-
auto requirements = getSpecializedSignature()->requirementsNotSatisfiedBy(
3037-
getFunction()->getGenericEnvironment()->getGenericSignature());
3036+
ArrayRef<Requirement> requirements;
3037+
SmallVector<Requirement, 4> requirementsScratch;
3038+
if (auto specializedSig = getSpecializedSignature()) {
3039+
if (auto env = getFunction()->getGenericEnvironment()) {
3040+
requirementsScratch = specializedSig->requirementsNotSatisfiedBy(
3041+
env->getGenericSignature());
3042+
requirements = requirementsScratch;
3043+
} else {
3044+
requirements = specializedSig->getRequirements();
3045+
}
3046+
}
30383047
if (!requirements.empty()) {
30393048
OS << "where ";
30403049
SILFunction *F = getFunction();

0 commit comments

Comments
 (0)