sun::support
namespace · Source (opens in a new tab)
Provides shared diagnostics, source tracking, and compiler utilities.
Formats messages written by the compiler and its command-line tools.
Provides source locations, diagnostics, and shared compiler utilities.
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.
Classes
- sun::support::SunError (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)
Functions
- formatDiagnostic
- isKnownTargetOs
- logAndThrowError
- logErrorNoThrow
- logMessage
- logParsingError
- logSemanticError
- logTypeError
- logWarning
- messagePrefix
- messageStream
- nextSourceFileId
- resolvedTargetTriple
- targetOsName
- terminalColors
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
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.
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
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 a compiler message on stdout for info or stderr for diagnostics.
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
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.
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.