slang::SourceLocation class

This class represents a location in source code (or within a macro expansion).

The SourceManager can decode this into file, line, and column information if it's a file location, or into expanded and original locations if it's a macro location.

Public static variables

static const SourceLocation NoLocation
A location that is reserved to represent "no location" at all.

Constructors, destructors, conversion operators

operator bool() const explicit

Public functions

auto buffer() const -> BufferID
auto offset() const -> size_t
auto valid() const -> bool
template<std::integral T>
auto operator+(T delta) const -> SourceLocation
Computes a source location that is offset from the current one.

Function documentation

slang::SourceLocation::operator bool() const explicit

Returns true if the location is valid, and false if not.

BufferID slang::SourceLocation::buffer() const

Returns an identifier for the buffer that contains this location.

size_t slang::SourceLocation::offset() const

Returns the character offset of this location within the source buffer.

bool slang::SourceLocation::valid() const

Returns true if the location is valid, and false if not.

template<std::integral T>
SourceLocation slang::SourceLocation::operator+(T delta) const

Computes a source location that is offset from the current one.

Note that there is no error checking to ensure that the location still points to a valid place in the source.