FLANG
Static Public Member Functions | List of all members
Fortran::frontend::TextDiagnostic Class Reference

#include <flang/Frontend/TextDiagnostic.h>

Static Public Member Functions

static void printDiagnosticLevel (llvm::raw_ostream &os, clang::DiagnosticsEngine::Level level, bool showColors)
 
static void printDiagnosticMessage (llvm::raw_ostream &os, bool isSupplemental, llvm::StringRef message, bool showColors)
 

Detailed Description

Class to encapsulate the logic for formatting and printing a textual diagnostic message.

The purpose of this class is to isolate the implementation of printing beautiful text diagnostics from any particular interfaces. Currently only simple diagnostics that lack source location information are supported (e.g. Flang driver errors).

In the future we can extend this class (akin to Clang) to support more complex diagnostics that would include macro backtraces, caret diagnostics, FixIt Hints and code snippets.

Member Function Documentation

◆ printDiagnosticLevel()

void TextDiagnostic::printDiagnosticLevel ( llvm::raw_ostream &  os,
clang::DiagnosticsEngine::Level  level,
bool  showColors 
)
static

Print the diagnostic level to a llvm::raw_ostream.

This is a static helper that handles colorizing the level and formatting it into an arbitrary output stream.

Parameters
osWhere the message is printed
levelThe diagnostic level (e.g. error or warning)
showColorsEnable colorizing of the message.

◆ printDiagnosticMessage()

void TextDiagnostic::printDiagnosticMessage ( llvm::raw_ostream &  os,
bool  isSupplemental,
llvm::StringRef  message,
bool  showColors 
)
static

Pretty-print a diagnostic message to a llvm::raw_ostream.

This is a static helper to handle the colorizing and rendering diagnostic message to a particular ostream. In the future we can extend it to support e.g. line wrapping. It is publicly visible as at this stage we don't require any state data to print a diagnostic.

Parameters
osWhere the message is printed
isSupplementaltrue if this is a continuation note diagnostic
messageThe text actually printed
showColorsEnable colorizing of the message.

The documentation for this class was generated from the following files: