From 899c2af576124df2918fd2ae976434df0ebbae5b Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 21 Oct 2026 14:06:54 +0000 Subject: feat(driver): color diagnostics like gcc with -fdiagnostics-color Add -fdiagnostics-color[=auto|always|never] and -fno-diagnostics-color. The default auto mode colors only a terminal stderr (TERM set and not dumb on Unix; a console that accepts VT sequences on Windows), so test harnesses, the desktop bundle and other pipes stay plain. Every diagnostic label now comes from cps::diagnosticPrefix, which emits gcc's default GCC_COLORS bytes: bold locus, bold red error/fatal error, bold magenta warning, bold cyan note. compilation terminated., runtime messages of the compiled program and lld output are unchanged. Co-Authored-By: Claude Opus 5.5 --- tools/driver/StandardLibrary.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tools/driver/StandardLibrary.cc') diff --git a/tools/driver/StandardLibrary.cc b/tools/driver/StandardLibrary.cc index ac88745..7680054 100644 --- a/tools/driver/StandardLibrary.cc +++ b/tools/driver/StandardLibrary.cc @@ -1,4 +1,5 @@ #include "StandardLibrary.h" +#include "cps/Diagnostics.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -19,7 +20,8 @@ StandardLibrary::~StandardLibrary() { bool StandardLibrary::load(std::vector &Inputs) { auto Error = llvm::sys::fs::createUniqueDirectory("cpsc-std", Directory); if (Error) { - llvm::errs() << "cpsc: fatal error: cannot extract standard library: " << Error.message() << "\n"; + llvm::errs() << cps::diagnosticPrefix(cps::Severity::Fatal) + << "cannot extract standard library: " << Error.message() << "\n"; return false; } for (const auto &File : LibraryFiles) { @@ -32,8 +34,9 @@ bool StandardLibrary::load(std::vector &Inputs) { Error = Output.error(); } if (Error) { - llvm::errs() << "cpsc: fatal error: cannot extract standard library file '" - << File.Name << "': " << Error.message() << "\n"; + llvm::errs() << cps::diagnosticPrefix(cps::Severity::Fatal) + << "cannot extract standard library file '" << File.Name + << "': " << Error.message() << "\n"; Output.clear_error(); return false; } -- cgit v1.3.1-4-g156e