When a CU attaches some ranges for a subprogram or an inlined code, the CU should be that of the subprogram/inlined code that was emitted.
If not, then these emitted ranges will use the incorrect base of the CU in emitRangeList.
A reproducible example is:
When linking these two LLVM IRs, dsymutil will report no mapping for range or inconsistent range data warnings.
foo.swift
swift
import AppKit.NSLayoutConstraint
public class Foo {
public var c: Int {
get {
Int(NSLayoutConstraint().constant)
}
set {
}
}
}main.swift
swift // no mapping for range let f: Foo! = nil // inconsistent range data //let l: Foo = Foo()
I made an Xcode project for this example.
ContextCU should probably be passed by reference-to-pointer - since you've updated the two callers so they don't pass null, there's no need for the implementation to consider whether the caller might've passed null, I think?
Alternatively, I guess, the caller could perform the lookup again, since they got the DIE back as a result, right? Maybe that's better than threading this through all the construct* abstractions to get it back out again?