APIs for loading and managing source code for compilation.
The SourceManager operates on "buffers", which are groups of source code. Source files are one kind of buffer, which can be added to the manager via the slang::
SourceManager sm; SourceBuffer buffer = sm.readSource("path/to/mySource.sv");
In addition to reading source from disk, you can also pass source in directly via the slang::
SourceManager sm; SourceBuffer buffer = sm.assignText("module m; endmodule");
Besides files, macro expansions are the other kind of buffer that can be tracked by the manager. Each macro expansion constitutes a new buffer, and tracks both where the original macro text came from as well as where the expansion is occurring.
It's important to be able to concisely represent locations in the user's original source code so that accurate diagnostics can be issued. The slang::
SourceLocation is designed to be compact; in release mode it consumes only 8 bytes. In order to learn useful things about that location you need the SourceManager that originally created it. SourceManager has many methods for querying information about source locations; see the API reference for more details.
In debug builds each SourceLocation includes the textual name of the buffer with which it is associated, to ease inspection when viewing locations in a debugger.