sun::support
namespace · Source (opens in a new tab)
Provides shared diagnostics, source tracking, and compiler utilities.
Implements reusable file links and tree layouts for terminal diagnostics.
Keeps display-only path policy separate from source and artifact identity.
Renders structured compiler diagnostics for the destination terminal.
Formats messages written by the compiler and its command-line tools.
Makes recorded source locations portable without changing compiler input paths.
Shared utilities used throughout the compiler.
Provides source locations, diagnostics, and shared compiler utilities.
Renders file names without changing the paths used by the compiler.
Owns a semantic analysis session and its cooperating analyzers.
The pipeline orders declaration preparation and body analysis. The single node entry point establishes source context and dispatches to declaration, statement, or expression checking; specialized analyzers own the rules. Provides shared diagnostics, source tracking, and compiler utilities.
Formats source locations stored in generated code and Moon declarations.
Renders paths for the current compiler invocation.
Classes
- sun::support::DisplayPathScope (public)
- sun::support::BuildProgressScope (public)
- sun::support::SunError (public)
- sun::support::SaveAndRestore (public)
- sun::support::SourceManager (public)
- sun::support::StageTimings (public)
- sun::support::ScopedStage (public)
- sun::support::SunPath (public)
Structs
- sun::support::Config (public)
- sun::support::RelatedDiagnostic (public)
- sun::support::Position (public)
- sun::support::StageTimingsReporter (public)
- sun::support::TerminalTreeNode (public)
Functions
- displayPath
- displayPathBase
- displayPosition
- formatDiagnostic
- isKnownTargetOs
- logAndThrowError
- logBuildProgress
- logErrorNoThrow
- logMessage
- logParsingError
- logPathMessage
- logSemanticError
- logTypeError
- logWarning
- messageEnabled
- messagePrefix
- messageStream
- nextSourceFileId
- relativeSourcePath
- resolvedTargetTriple
- targetOsName
- terminalColors
- terminalFileLabel
- terminalStyledText
- terminalTree
displayPath
public · function · Source (opens in a new tab)
std::string sun::support::displayPath(const std::filesystem::path &path)Makes paths inside the selected directory relative; outside paths stay absolute.
Without an active CLI scope, preserves the caller's spelling.
displayPathBase
public · function · Source (opens in a new tab)
std::filesystem::path sun::support::displayPathBase()Returns the display base for child build contexts, or the current directory.
displayPosition
public · function · Source (opens in a new tab)
std::string sun::support::displayPosition(Position position)Formats a source location using display paths, preserving its stored value.
Related: Position
formatDiagnostic
public · function · Source (opens in a new tab)
std::string sun::support::formatDiagnostic(const std::string &label, const std::string &labelColor, const std::string &message, const std::optional< Position > &location, const std::string &sourceLine, const std::string &prevSourceLine)Render a diagnostic in the standard compiler format: colored label, blue file:line:column, the message, then the offending source line with a red caret under the column.
Shared by SunError and multi-error passes like the borrow checker, so every compiler error looks the same.
isKnownTargetOs
public · function · Source (opens in a new tab)
bool sun::support::isKnownTargetOs(const std::string &name)Whether name is an OS name Sun knows.
Both users of the vocabulary reject unknown names outright, so a typo is a compile error rather than a silently never-matching selector.
logAndThrowError
public · function · Source (opens in a new tab)
void sun::support::logAndThrowError(const std::string &str, std::optional< Position > loc=std::nullopt)Reports a compilation error and throws an exception to stop the current operation.
Related: Position
logBuildProgress
public · function · Source (opens in a new tab)
void sun::support::logBuildProgress(const std::string &label, const std::filesystem::path &output, const std::optional< std::filesystem::path > &source=std::nullopt)Logs a configured entrypoint ID, or a basename for an unconfigured output.
Existing files remain linked in formatted terminals. Debug logging includes full artifact and optional source paths.
logErrorNoThrow
public · function · Source (opens in a new tab)
void sun::support::logErrorNoThrow(const std::string &msg, std::optional< Position > loc=std::nullopt)Log error without throwing - useful for non-fatal diagnostics.
Related: Position
logMessage
public · function · Source (opens in a new tab)
void sun::support::logMessage(const std::string &level, const std::string &message)Writes each line of a complete message with its own severity prefix.
logParsingError
logParsingError(const Position &loc, const std::string &str, const std::string &sourceLine="", const std::string &prevLine="")
public · function · Source (opens in a new tab)
void sun::support::logParsingError(const Position &loc, const std::string &str, const std::string &sourceLine="", const std::string &prevLine="")Overload accepting Position directly (preferred for new code).
logParsingError(int line, int column, const std::string &str, const std::string &sourceLine="", const std::string &filePath="")
public · function · Source (opens in a new tab)
void sun::support::logParsingError(int line, int column, const std::string &str, const std::string &sourceLine="", const std::string &filePath="")Reports invalid syntax with its source location and line text.
logPathMessage
public · function · Source (opens in a new tab)
void sun::support::logPathMessage(const std::string &level, const std::string &label, const std::filesystem::path &path, const std::optional< std::filesystem::path > &output=std::nullopt)Writes and flushes a progress message with one path or an input/output pair.
Paths follow the active display policy; disabled levels produce no output.
logSemanticError
public · function · Source (opens in a new tab)
void sun::support::logSemanticError(const std::string &str, std::optional< Position > loc=std::nullopt)Reports a semantic error with its optional source position.
Related: Position
logTypeError
public · function · Source (opens in a new tab)
void sun::support::logTypeError(const std::string &str, std::optional< Position > loc=std::nullopt)Reports a type error with its optional source position.
Related: Position
logWarning
public · function · Source (opens in a new tab)
void sun::support::logWarning(const std::string &msg, std::optional< Position > loc=std::nullopt)Non-fatal diagnostic (e.g.
unreachable match arms)
Related: Position
messageEnabled
public · function · Source (opens in a new tab)
bool sun::support::messageEnabled(const std::string &level)Filters progress and warnings using SUN_LOG_LEVEL (debug, info, warn, or error).
Missing or unrecognized values use info; errors and diagnostic notes remain visible at every level.
messagePrefix
public · function · Source (opens in a new tab)
std::string sun::support::messagePrefix(const std::string &level, llvm::raw_ostream &stream)Builds a severity prefix, coloring it only for an interactive terminal.
messageStream
public · function · Source (opens in a new tab)
llvm::raw_ostream & sun::support::messageStream(const std::string &level)Starts an enabled compiler message, discarding messages below the threshold.
nextSourceFileId
public · function · Source (opens in a new tab)
SourceFileId sun::support::nextSourceFileId()Allocate a distinct identity for a parsed or loaded source unit.
Related: SourceFileId
relativeSourcePath
public · function · Source (opens in a new tab)
std::string sun::support::relativeSourcePath(const std::string &path, const std::string &entrypointDirectory)Makes absolute source paths relative to the entrypoint directory; already relative paths retain the originating library's base.
resolvedTargetTriple
public · function · Source (opens in a new tab)
llvm::Triple sun::support::resolvedTargetTriple(const std::string &targetTriple)The triple a compilation is actually for: the explicit target, or the host when none was given.
Normalized first: a raw llvm::Triple parses components by position, so the common three-part spelling "aarch64-linux-gnu" would read "linux" as a vendor and report an unknown OS.
targetOsName
public · function · Source (opens in a new tab)
std::optional< std::string > sun::support::targetOsName(const llvm::Triple &triple)The Sun OS name for a triple, or nullopt for an OS Sun has no name for.
terminalColors
public · function · Source (opens in a new tab)
bool sun::support::terminalColors(llvm::raw_ostream &stream)Returns whether a terminal stream should receive ANSI colors.
terminalFileLabel
public · function · Source (opens in a new tab)
std::string sun::support::terminalFileLabel(const std::filesystem::path &path, llvm::raw_ostream &stream, const std::string &label="")Links an existing file with a solid yellow underline and unchanged text color.
The optional label replaces the basename; an OSC link retains the full path. Missing files, filesystem errors, and disabled formatting use plain text.
terminalStyledText
public · function · Source (opens in a new tab)
std::string sun::support::terminalStyledText(const std::string &text, const std::string &level, llvm::raw_ostream &stream)Styles text with a severity color, leaving redirected output unchanged.
terminalTree
public · function · Source (opens in a new tab)
std::string sun::support::terminalTree(const TerminalTreeNode &root, llvm::raw_ostream &stream, const std::string &level="warning", const std::string &indent="")Renders a tree with solid connectors, styling them with the given severity.
The root has no connector. Every line receives indent; no trailing newline is added. Detail lines follow their label before child branches.
Related: TerminalTreeNode
Variables
blue
public · variable · Source (opens in a new tab)
const char* sun::support::blue = "\033[1;34m"No documentation comment.
cyan
public · variable · Source (opens in a new tab)
const char* sun::support::cyan = "\033[36m"No documentation comment.
red
public · variable · Source (opens in a new tab)
const char* sun::support::red = "\033[1;31m"No documentation comment.
reset
public · variable · Source (opens in a new tab)
const char* sun::support::reset = "\033[0m"No documentation comment.
stageTimingsReporter
public · variable · Source (opens in a new tab)
const StageTimingsReporter sun::support::stageTimingsReporterNo documentation comment.
Related: StageTimingsReporter
yellow
public · variable · Source (opens in a new tab)
const char* sun::support::yellow = "\033[1;33m"No documentation comment.
Type Aliases
SourceFileId
public · typedef · Source (opens in a new tab)
using sun::support::SourceFileId = uint64_tIdentifies a source unit independently of its diagnostic path.
Zero is unset.