FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches

How a diagnostic lays out - and how much of it an Error keeps. More...

#include <fe/diag.h>

Inheritance diagram for fe::Diag:
[legend]

Public Types

enum class  Tag {
  Error ,
  Warn ,
  Note
}

Public Member Functions

 Diag ()=default
 Diag (const Diag &)=delete
virtual ~Diag ()
virtual std::string render (const std::function< std::string()> &fmt) const
 Postprocesses the text of one Error::Msg; the identity here, see CodeDiag.
Layout

Each of these streams one piece of a diagnostic; override to lay that piece out differently.

virtual void loc (std::ostream &, Loc) const
 Just the position.
virtual void header (std::ostream &, Loc, Tag, std::string_view) const
 The loc: tag: msg line.
virtual void snippet (std::ostream &, Loc, Tag) const
 The underlined source excerpt.
virtual void note (std::ostream &, Loc, std::string_view) const
 One note below the message it belongs to.
virtual void summary (std::ostream &, size_t num_errors, size_t num_warnings, bool truncated) const

Static Public Member Functions

static term::FG tag2color (Tag)

Public Attributes

uint32_t gutter = 5
 Width of the line-number column.
uint32_t max_rows = 8
 Rows a snippet streams before eliding its middle; 0 elides nothing.
uint32_t max_errors = 0
 Errors recorded before the rest is dropped; 0 keeps everything.
bool no_snippet = false
 If true, a diagnostic is only its header line.
bool werror = false
 If true, a warning is recorded as an error.
Loc::Style loc_style = Loc::Style::Full
 How Diag::loc spells out a position.

Detailed Description

How a diagnostic lays out - and how much of it an Error keeps.

The knobs below cover the common adjustments; derive and Driver::diag your subclass for the rest.

Warning
A subclass that refers back to its Driver does not survive a move; keep the Driver pinned.

Definition at line 19 of file diag.h.

Member Enumeration Documentation

◆ Tag

enum class fe::Diag::Tag
strong
Enumerator
Error 
Warn 
Note 

Definition at line 21 of file diag.h.

Constructor & Destructor Documentation

◆ Diag() [1/2]

fe::Diag::Diag ( )
default

Referenced by Diag().

◆ Diag() [2/2]

fe::Diag::Diag ( const Diag & )
delete

References Diag().

◆ ~Diag()

virtual fe::Diag::~Diag ( )
virtual

Member Function Documentation

◆ header()

virtual void fe::Diag::header ( std::ostream & ,
Loc ,
Tag ,
std::string_view  ) const
virtual

The loc: tag: msg line.

◆ loc()

virtual void fe::Diag::loc ( std::ostream & ,
Loc  ) const
virtual

Just the position.

◆ note()

virtual void fe::Diag::note ( std::ostream & ,
Loc ,
std::string_view  ) const
virtual

One note below the message it belongs to.

◆ render()

virtual std::string fe::Diag::render ( const std::function< std::string()> & fmt) const
inlinevirtual

Postprocesses the text of one Error::Msg; the identity here, see CodeDiag.

Warning
fmt captures its arguments by reference and is only valid for that one call.

Reimplemented in fe::CodeDiag.

Definition at line 50 of file diag.h.

◆ snippet()

virtual void fe::Diag::snippet ( std::ostream & ,
Loc ,
Tag  ) const
virtual

The underlined source excerpt.

◆ summary()

virtual void fe::Diag::summary ( std::ostream & ,
size_t num_errors,
size_t num_warnings,
bool truncated ) const
virtual

Referenced by fe::Error::operator<<.

◆ tag2color()

term::FG fe::Diag::tag2color ( Tag )
static

Member Data Documentation

◆ gutter

uint32_t fe::Diag::gutter = 5

Width of the line-number column.

Definition at line 31 of file diag.h.

◆ loc_style

Loc::Style fe::Diag::loc_style = Loc::Style::Full

How Diag::loc spells out a position.

Definition at line 36 of file diag.h.

◆ max_errors

uint32_t fe::Diag::max_errors = 0

Errors recorded before the rest is dropped; 0 keeps everything.

Definition at line 33 of file diag.h.

◆ max_rows

uint32_t fe::Diag::max_rows = 8

Rows a snippet streams before eliding its middle; 0 elides nothing.

Definition at line 32 of file diag.h.

◆ no_snippet

bool fe::Diag::no_snippet = false

If true, a diagnostic is only its header line.

Definition at line 34 of file diag.h.

◆ werror

bool fe::Diag::werror = false

If true, a warning is recorded as an error.

Definition at line 35 of file diag.h.


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