Skip to content

Commit 2678788

Browse files
committed
IRGen: Set artifical functions for key path code
Otherwise, debug info asserts get triggered because of a missing debug loc. rdar://36797675
1 parent bf439cd commit 2678788

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/IRGen/GenKeyPath.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ getLayoutFunctionForComputedComponent(IRGenModule &IGM,
258258

259259
{
260260
IRGenFunction IGF(IGM, layoutFn);
261+
if (IGM.DebugInfo)
262+
IGM.DebugInfo->emitArtificialFunction(IGF, layoutFn);
261263
// Unmarshal the generic environment from the argument buffer.
262264
auto parameters = IGF.collectParameters();
263265
auto args = parameters.claimNext();
@@ -509,6 +511,9 @@ getInitializerForComputedComponent(IRGenModule &IGM,
509511

510512
{
511513
IRGenFunction IGF(IGM, initFn);
514+
if (IGM.DebugInfo)
515+
IGM.DebugInfo->emitArtificialFunction(IGF, initFn);
516+
512517
auto params = IGF.collectParameters();
513518
// Pointer to the argument packet passed into swift_getKeyPath
514519
auto src = params.claimNext();

test/DebugInfo/keypath.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-swift-frontend -g -emit-ir %s | %FileCheck %s
2+
3+
public struct Gen<Value> {
4+
public private(set) var value: Value
5+
public func use<Subject>(keyPath: WritableKeyPath<Value, Subject>) {
6+
}
7+
}
8+
9+
// This used to assert.
10+
11+
// CHECK: distinct !DISubprogram(linkageName: "keypath_set", {{.*}} flags: DIFlagArtificial
12+
extension Gen where Value : MutableCollection, Value.Index : Hashable {
13+
public var dontAssert: Int {
14+
var i = value.startIndex
15+
use(keyPath: \.[i])
16+
return 0
17+
}
18+
}

0 commit comments

Comments
 (0)