Skip to content

Commit c1ea315

Browse files
Merge pull request swiftlang#40897 from aschwaighofer/generic_specializer_debug_info
GenericCloner: Generate a valid debug location if no decl is available for a SILArgument
2 parents 4b217bc + 2bc8ad2 commit c1ea315

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/SILOptimizer/Utils/GenericCloner.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ void GenericCloner::populateCloned() {
7272
SmallVector<SILValue, 4> entryArgs;
7373
entryArgs.reserve(OrigEntryBB->getArguments().size());
7474
for (auto &OrigArg : OrigEntryBB->getArguments()) {
75-
RegularLocation Loc((Decl *)OrigArg->getDecl());
75+
RegularLocation Loc = OrigArg->getDecl() ?
76+
RegularLocation((Decl *)OrigArg->getDecl()) :
77+
RegularLocation::getAutoGeneratedLocation();
7678
AllocStackInst *ASI = nullptr;
7779
SILType mappedType = remapType(OrigArg->getType());
7880

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-swift-frontend %s -O -enable-library-evolution -emit-ir -g
2+
3+
// REQUIRES: objc_interop
4+
import Foundation
5+
6+
public struct MyThing {}
7+
8+
public struct ThingSequence: Sequence, IteratorProtocol {
9+
private var enumerator: NSEnumerator?
10+
11+
public init() { }
12+
13+
public mutating func next() -> MyThing? {
14+
guard let enumerator = enumerator else { return nil }
15+
guard let nextObject = enumerator.nextObject(),
16+
let nextThing = nextObject as? MyThing else {
17+
self.enumerator = nil
18+
return nil
19+
}
20+
return nextThing
21+
}
22+
}
23+
24+
public struct Manager {
25+
public func sequence() -> ThingSequence {
26+
ThingSequence()
27+
}
28+
}
29+
30+
public func test(m: Manager) {
31+
for _ in m.sequence() { }
32+
}

0 commit comments

Comments
 (0)