Mojo function
call_location
call_location[*, inline_count: Int = 1]() -> SourceLocation
Returns the location for where the caller of this function is called.
An optional inline_count parameter can be specified to skip over that many
levels of calling functions.
This should only be used when enclosed in a series of @always_inline or
@always_inline("nodebug") function calls, where the layers of calling
functions is no fewer than inline_count.
For example, when inline_count = 1, only the caller of this function needs
to be @always_inline or @always_inline("nodebug"). This function will
return the source location of the caller's invocation.
When inline_count = 2, the caller of the caller of this function also
needs to be inlined. This function will return the source location of the
caller's caller's invocation.
This currently doesn't work when the inline_count-th wrapping caller is
called in a parameter expression.
Parameters:
- inline_count (
Int): The number of inline call levels to skip.
Returns:
SourceLocation: The location information of where the caller of this function (i.e. the
function whose body call_location() is used in) is called.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!