Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

getInlineeSourceLines

Returns all pdb.InlineeSourceLines for a given module with the given inlinee. Ideally there would only be one entry per inlinee, but LLVM appears to assign all functions that share a name the same inlinee ID. This is a bug: https://github.com/llvm/llvm-project/issues/191787 The best the caller can do right now is print all the results.

Pdb.getInlineeSourceLines
pub fn getInlineeSourceLines(self: *Pdb, mod: *Module, inlinee: u32) InlineeSourceLocationIterator

File

lib/std/debug/Pdb.zig:718

Code

pub fn getInlineeSourceLines(self: *Pdb, mod: *Module, inlinee: u32) InlineeSourceLocationIterator {
    _ = self;

    // Binary search to an arbitrary match, if there are other matches they will be adjacent
    const any = std.sort.binarySearch(
        *align(1) const pdb.InlineeSourceLine,
        mod.inlinee_source_lines,
        inlinee,
        compareInlineeSourceLineInlinee,
    ) orelse return .empty;

    // Linearly scan to the first match
    const begin = b: {
        var begin = any;
        while (begin > 0) {
            const prev = begin - 1;
            if (mod.inlinee_source_lines[prev].inlinee != inlinee) break;
            begin = prev;
        }
        break :b begin;
    };

    // Linearly scan to the last match
    const end = b: {
        var end = any + 1;
        while (end < mod.inlinee_source_lines.len and
            mod.inlinee_source_lines[end].inlinee == inlinee) : (end += 1)
        {}
        break :b end;
    };

    // Return an iterator over all matches (the iterator filters out duplicate entries)
    return .{ .lines = mod.inlinee_source_lines[begin..end] };
}