Skip to content

Commit ad07016

Browse files
committed
Don't print AST if-clauses when emitting SIL.
It's not required and also this crashed while emitting the SIL of the stdlib build.
1 parent 5b5060e commit ad07016

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ struct PrintOptions {
465465
result.PrintForSIL = true;
466466
result.PrintInSILBody = true;
467467
result.PreferTypeRepr = false;
468+
result.PrintIfConfig = false;
468469
return result;
469470
}
470471

test/SIL/if_clause_printing.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -emit-sil %s | %FileCheck %s
2+
3+
// Check that we don't crash when trying to print an inactive if-clause.
4+
5+
// CHECK: struct TestStruct
6+
// CHECK-NEXT: internal enum TheRealOne
7+
// CHECK-NEXT: case B
8+
9+
struct TestStruct {
10+
#if abc
11+
internal enum Unused {
12+
case A(AnyObject)
13+
}
14+
#else
15+
internal enum TheRealOne {
16+
case B(AnyObject)
17+
}
18+
#endif
19+
}
20+

0 commit comments

Comments
 (0)