Skip to content

Commit 6e03342

Browse files
committed
Parser: Don't skip functions with a nested typealias or actor for LLDB
The flag -experimental-skip-non-inlinable-function-bodies-without-types is built in the emit-module-separately phase to quickly extract the API of the target module. It is designed to not skip functions with nested types as these are used by LLDB. This logic relies on a simple heuristic to find nested type. Let's make sure it detects tyealiases and actors. rdar://120928396
1 parent 8b22079 commit 6e03342

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

Diff for: lib/Parse/ParseDecl.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -5625,7 +5625,8 @@ 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+
|| P.Tok.isContextualKeyword("actor");
56295630

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

Diff for: test/Frontend/skip-function-bodies.swift

+26-5
Original file line numberDiff line numberDiff line change
@@ -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,26 @@ 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+
199220
public func funcPublicWithNestedTypeStruct() {
200221
let INLINENOTYPECHECK_local = "funcPublicWithNestedTypeStruct()"
201222
_blackHole(INLINENOTYPECHECK_local)

0 commit comments

Comments
 (0)