Skip to content

Commit 9130ed9

Browse files
authored
Merge pull request #72782 from xymus/skip-without-types-more-6.0
[6.0] Parser: Don't skip functions with a nested typealias, protocol or actor for LLDB
2 parents dcf078a + 59c1b99 commit 9130ed9

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5625,7 +5625,9 @@ static unsigned skipUntilMatchingRBrace(Parser &P,
56255625
tok::pound_if, tok::pound_else, tok::pound_endif, tok::pound_elseif);
56265626

56275627
HasNestedTypeDeclarations |= P.Tok.isAny(tok::kw_class, tok::kw_struct,
5628-
tok::kw_enum);
5628+
tok::kw_enum, tok::kw_typealias,
5629+
tok::kw_protocol)
5630+
|| P.Tok.isContextualKeyword("actor");
56295631

56305632
// HACK: Bail if we encounter what could potentially be a regex literal.
56315633
// This is necessary as:

test/Frontend/skip-function-bodies.swift

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
// Check skipped function bodies are neither typechecked nor SILgen'd when the
44
// -experimental-skip-*-function-bodies-* flags are specified.
5-
// RUN: %target-swift-frontend -emit-sil %s > %t/NoSkip.sil
5+
// RUN: %target-swift-frontend -emit-sil -target %target-swift-abi-5.10-triple %s > %t/NoSkip.sil
66
// RUN: %target-swift-frontend -emit-sil -experimental-skip-non-inlinable-function-bodies -debug-forbid-typecheck-prefix NEVERTYPECHECK -debug-forbid-typecheck-prefix INLINENOTYPECHECK %s > %t/Skip.noninlinable.sil
7-
// RUN: %target-swift-frontend -emit-sil -experimental-skip-non-inlinable-function-bodies-without-types -debug-forbid-typecheck-prefix NEVERTYPECHECK %s > %t/Skip.withouttypes.sil
7+
// RUN: %target-swift-frontend -emit-sil -target %target-swift-abi-5.10-triple -experimental-skip-non-inlinable-function-bodies-without-types -debug-forbid-typecheck-prefix NEVERTYPECHECK %s > %t/Skip.withouttypes.sil
88

99
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-SIL-NO-SKIP --input-file %t/NoSkip.sil
1010
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-SIL-SKIP-NONINLINE-OR-WITHOUTTYPES,CHECK-SIL-SKIP-NONINLINE --input-file %t/Skip.noninlinable.sil
@@ -14,16 +14,16 @@
1414
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-SIL-SKIP-ALL --input-file %t/Skip.all.sil
1515

1616
// Emit module interfaces and check their contents, too.
17-
// RUN: %target-swift-emit-module-interface(%t/Skip.noninlinable.swiftinterface) %s -module-name Skip -experimental-skip-non-inlinable-function-bodies
17+
// RUN: %target-swift-emit-module-interface(%t/Skip.noninlinable.swiftinterface) %s -target %target-swift-abi-5.10-triple -module-name Skip -experimental-skip-non-inlinable-function-bodies
1818
// RUN: %target-swift-typecheck-module-from-interface(%t/Skip.noninlinable.swiftinterface) -module-name Skip
1919
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-TEXTUAL --input-file %t/Skip.noninlinable.swiftinterface
20-
// RUN: %target-swift-emit-module-interface(%t/Skip.all.swiftinterface) %s -module-name Skip -experimental-skip-all-function-bodies
20+
// RUN: %target-swift-emit-module-interface(%t/Skip.all.swiftinterface) %s -target %target-swift-abi-5.10-triple -module-name Skip -experimental-skip-all-function-bodies
2121
// RUN: %target-swift-typecheck-module-from-interface(%t/Skip.all.swiftinterface) -module-name Skip
2222
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-TEXTUAL --input-file %t/Skip.all.swiftinterface
2323

2424
// Verify that the emitted interfaces match an interface emitted without any
2525
// body skipping flags.
26-
// RUN: %target-swift-emit-module-interface(%t/NoSkip.swiftinterface) %s -module-name Skip
26+
// RUN: %target-swift-emit-module-interface(%t/NoSkip.swiftinterface) %s -target %target-swift-abi-5.10-triple -module-name Skip
2727
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-TEXTUAL --input-file %t/NoSkip.swiftinterface
2828
// RUN: diff -u %t/Skip.noninlinable.swiftinterface %t/NoSkip.swiftinterface
2929
// RUN: diff -u %t/Skip.all.swiftinterface %t/NoSkip.swiftinterface
@@ -158,19 +158,20 @@ func funcPublicWithDefer() {
158158
// CHECK-SIL-SKIP-NONINLINE-OR-WITHOUTTYPES-NOT: "funcPublicWithDefer()"
159159

160160
public func funcPublicWithNestedFuncAndTypealias() {
161-
let NEVERTYPECHECK_outerLocal = "funcPublicWithNestedFuncAndTypealias()"
162-
_blackHole(NEVERTYPECHECK_outerLocal)
161+
let INLINENOTYPECHECK_outerLocal = "funcPublicWithNestedFuncAndTypealias()"
162+
_blackHole(INLINENOTYPECHECK_outerLocal)
163163

164164
typealias LocalType = Int
165165
func takesLocalType(_ x: LocalType) {
166-
let NEVERTYPECHECK_innerLocal = "funcPublicWithNestedFuncAndTypealias()@takesLocalType(_:)"
167-
_blackHole(NEVERTYPECHECK_innerLocal)
166+
let INLINENOTYPECHECK_innerLocal = "funcPublicWithNestedFuncAndTypealias()@takesLocalType(_:)"
167+
_blackHole(INLINENOTYPECHECK_innerLocal)
168168
}
169169
takesLocalType(0)
170170
}
171171
// CHECK-TEXTUAL-NOT: "funcPublicWithNestedFuncAndTypealias()"
172172
// CHECK-SIL-NO-SKIP: "funcPublicWithNestedFuncAndTypealias()"
173-
// CHECK-SIL-SKIP-NONINLINE-OR-WITHOUTTYPES-NOT: "funcPublicWithNestedFuncAndTypealias()"
173+
// CHECK-SIL-SKIP-WITHOUTTYPES: "funcPublicWithNestedFuncAndTypealias()"
174+
// CHECK-SIL-SKIP-NONINLINE-NOT: "funcPublicWithNestedFuncAndTypealias()"
174175

175176
// CHECK-TEXTUAL-NOT: "funcPublicWithNestedFuncAndTypealias()@takesLocalType(_:)"
176177
// CHECK-SIL-NO-SKIP: "funcPublicWithNestedFuncAndTypealias()@takesLocalType(_:)"
@@ -196,6 +197,36 @@ public func funcPublicWithNestedTypeEnum() {
196197
// CHECK-SIL-SKIP-NONINLINE-NOT: "funcPublicWithNestedTypeEnum()"
197198
// CHECK-SIL-SKIP-WITHOUTTYPES: "funcPublicWithNestedTypeEnum()"
198199

200+
public func funcPublicWithNestedTypealias() {
201+
let INLINENOTYPECHECK_local = "funcPublicWithNestedTypealias()"
202+
_blackHole(INLINENOTYPECHECK_local)
203+
typealias TA = Int
204+
}
205+
// CHECK-TEXTUAL-NOT: "funcPublicWithNestedTypealias()"
206+
// CHECK-SIL-NO-SKIP: "funcPublicWithNestedTypealias()"
207+
// CHECK-SIL-SKIP-NONINLINE-NOT: "funcPublicWithNestedTypealias()"
208+
// CHECK-SIL-SKIP-WITHOUTTYPES: "funcPublicWithNestedTypealias()"
209+
210+
public func funcPublicWithNestedTypeActor() {
211+
let INLINENOTYPECHECK_local = "funcPublicWithNestedTypeActor()"
212+
_blackHole(INLINENOTYPECHECK_local)
213+
actor A {}
214+
}
215+
// CHECK-TEXTUAL-NOT: "funcPublicWithNestedTypeActor()"
216+
// CHECK-SIL-NO-SKIP: "funcPublicWithNestedTypeActor()"
217+
// CHECK-SIL-SKIP-NONINLINE-NOT: "funcPublicWithNestedTypeActor()"
218+
// CHECK-SIL-SKIP-WITHOUTTYPES: "funcPublicWithNestedTypeActor()"
219+
220+
public func funcPublicWithNestedTypeProtocol() {
221+
let INLINENOTYPECHECK_local = "funcPublicWithNestedTypeProtocol()"
222+
_blackHole(INLINENOTYPECHECK_local)
223+
protocol P {}
224+
}
225+
// CHECK-TEXTUAL-NOT: "funcPublicWithNestedTypeProtocol()"
226+
// CHECK-SIL-NO-SKIP: "funcPublicWithNestedTypeProtocol()"
227+
// CHECK-SIL-SKIP-NONINLINE-NOT: "funcPublicWithNestedTypeProtocol()"
228+
// CHECK-SIL-SKIP-WITHOUTTYPES: "funcPublicWithNestedTypeProtocol()"
229+
199230
public func funcPublicWithNestedTypeStruct() {
200231
let INLINENOTYPECHECK_local = "funcPublicWithNestedTypeStruct()"
201232
_blackHole(INLINENOTYPECHECK_local)

0 commit comments

Comments
 (0)