APIs that support issuing diagnostics.
Diagnostics diags; Diagnostic& diag = diags.add(diag::SomeDiagCode, location); diag << arg1 << arg2;
The slang::diag namespace contains all of the DiagCodes that are generated automatically as part of the build (sourced from the diagnostics.txt file). Each DiagCode is a combination of a slang::DiagSubsystem that indicates the general system that creates that kind of diagnostic and a simple index within that subsystem. It's also possible for a consumer of the slang library to create its own DiagCode and issue them via the diagnostic system.
Each Diagnostic that is issued to a DiagnosticEngine is formatted and, assuming it's not supressed, forwarded to all registered slang::
You can make a DiagnosticClient to do whatever you want, but the built in slang::
A basic example of setting up a diagnostic engine along with a text client:
DiagnosticEngine diagEngine(sourceManager); auto client = std::make_shared<TextDiagnosticClient>(); diagEngine.addClient(client); for (Diagnostic& diag : diags) diagEngine.issue(diag); std::string report = client->getString();