Skip to content

[5.0] IRGen: Set artifical functions for key path code #14116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/IRGen/GenKeyPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ getLayoutFunctionForComputedComponent(IRGenModule &IGM,

{
IRGenFunction IGF(IGM, layoutFn);
if (IGM.DebugInfo)
IGM.DebugInfo->emitArtificialFunction(IGF, layoutFn);
// Unmarshal the generic environment from the argument buffer.
auto parameters = IGF.collectParameters();
auto args = parameters.claimNext();
Expand Down Expand Up @@ -509,6 +511,9 @@ getInitializerForComputedComponent(IRGenModule &IGM,

{
IRGenFunction IGF(IGM, initFn);
if (IGM.DebugInfo)
IGM.DebugInfo->emitArtificialFunction(IGF, initFn);

auto params = IGF.collectParameters();
// Pointer to the argument packet passed into swift_getKeyPath
auto src = params.claimNext();
Expand Down
18 changes: 18 additions & 0 deletions test/DebugInfo/keypath.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %target-swift-frontend -g -emit-ir %s | %FileCheck %s

public struct Gen<Value> {
public private(set) var value: Value
public func use<Subject>(keyPath: WritableKeyPath<Value, Subject>) {
}
}

// This used to assert.

// CHECK: distinct !DISubprogram(linkageName: "keypath_set", {{.*}} flags: DIFlagArtificial
extension Gen where Value : MutableCollection, Value.Index : Hashable {
public var dontAssert: Int {
var i = value.startIndex
use(keyPath: \.[i])
return 0
}
}