Skip to content

Commit 1b09886

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 b90e96f commit 1b09886

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5623,7 +5623,8 @@ static unsigned skipUntilMatchingRBrace(Parser &P,
56235623
tok::pound_if, tok::pound_else, tok::pound_endif, tok::pound_elseif);
56245624

56255625
HasNestedTypeDeclarations |= P.Tok.isAny(tok::kw_class, tok::kw_struct,
5626-
tok::kw_enum);
5626+
tok::kw_enum, tok::kw_typealias)
5627+
|| P.Tok.isContextualKeyword("actor");
56275628

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

test/Frontend/skip-function-bodies.swift

Lines changed: 26 additions & 5 deletions
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)