mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
GenericCloner: Generate a valid debug location if no decl is available for a SILArgument
Without this we used to crash in a test case in IRGen trying to generate code for an invalid debug location. rdar://87565600
This commit is contained in:
@@ -72,7 +72,9 @@ void GenericCloner::populateCloned() {
|
||||
SmallVector<SILValue, 4> entryArgs;
|
||||
entryArgs.reserve(OrigEntryBB->getArguments().size());
|
||||
for (auto &OrigArg : OrigEntryBB->getArguments()) {
|
||||
RegularLocation Loc((Decl *)OrigArg->getDecl());
|
||||
RegularLocation Loc = OrigArg->getDecl() ?
|
||||
RegularLocation((Decl *)OrigArg->getDecl()) :
|
||||
RegularLocation::getAutoGeneratedLocation();
|
||||
AllocStackInst *ASI = nullptr;
|
||||
SILType mappedType = remapType(OrigArg->getType());
|
||||
|
||||
|
||||
32
test/DebugInfo/generic-specializer.swift
Normal file
32
test/DebugInfo/generic-specializer.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
// RUN: %target-swift-frontend %s -O -enable-library-evolution -emit-ir -g
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
import Foundation
|
||||
|
||||
public struct MyThing {}
|
||||
|
||||
public struct ThingSequence: Sequence, IteratorProtocol {
|
||||
private var enumerator: NSEnumerator?
|
||||
|
||||
public init() { }
|
||||
|
||||
public mutating func next() -> MyThing? {
|
||||
guard let enumerator = enumerator else { return nil }
|
||||
guard let nextObject = enumerator.nextObject(),
|
||||
let nextThing = nextObject as? MyThing else {
|
||||
self.enumerator = nil
|
||||
return nil
|
||||
}
|
||||
return nextThing
|
||||
}
|
||||
}
|
||||
|
||||
public struct Manager {
|
||||
public func sequence() -> ThingSequence {
|
||||
ThingSequence()
|
||||
}
|
||||
}
|
||||
|
||||
public func test(m: Manager) {
|
||||
for _ in m.sequence() { }
|
||||
}
|
||||
Reference in New Issue
Block a user