|
FE 0.13.1
Header-only C++ frontend library
|
Collects diagnostics and hands each to the Diag that lays it out. More...
#include <fe/error.h>
Classes | |
| class | Bail |
| What Error::ack and Error::bail throw. More... | |
| struct | Note |
| A secondary message elaborating a Msg. More... | |
| struct | Msg |
| One Tag::Error or Tag::Warn together with the Notes that belong to it. More... | |
Public Types | |
| using | Tag = Diag::Tag |
Public Member Functions | |
| Error (const Driver &driver) | |
| A sink of your own; Driver::error is the one every frontend building block already reports to. | |
Getters | |
| const auto & | msgs () const |
| bool | empty () const |
| bool | ok () const |
| Nothing recorded that must stop the compilation? | |
| size_t | num_errors () const |
| size_t | num_warnings () const |
| size_t | num_notes () const |
| bool | truncated () const |
| Did Diag::max_errors drop anything? | |
Add a Message | |
Each of these yields the Error again, so a diagnostic, its Notes, and a closing Error::bail chain. | |
| Error & | msg (Loc loc, Tag tag, const std::function< std::string()> &fmt) |
| template<class... Args> | |
| Error & | msg (Loc loc, Tag tag, std::format_string< Args... > s, Args &&... args) |
| template<class... Args> | |
| Error & | error (Loc loc, std::format_string< Args... > s, Args &&... args) |
| template<class... Args> | |
| Error & | warn (Loc loc, std::format_string< Args... > s, Args &&... args) |
| template<class... Args> | |
| Error & | note (std::format_string< Args... > s, Args &&... args) |
| A = note: continuation of the diagnostic being built; it has no Loc of its own to point at. | |
| template<class... Args> | |
| Error & | note (Loc loc, std::format_string< Args... > s, Args &&... args) |
A Note that points elsewhere; dropped when loc adds nothing. | |
Handle Errors/Warnings | |
| void | clear () |
| std::string | str (std::ostream &os=std::cerr) const |
Renders everything collected so far the way it would appear on os; os only decides the coloring. | |
| size_t | report (std::ostream &os=std::cerr) |
Streams everything collected so far to os and claims it. | |
| void | bail (std::ostream &os=std::cerr) |
Claims everything collected so far and throws it as a Bail rendered for os. | |
| void | ack (std::ostream &os=std::cerr) |
If errors occurred, Error::bail; otherwise Error::report any warnings to os. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Error &e) |
| Hands every Msg, its Notes, and the closing summary to Diag. | |
Collects diagnostics and hands each to the Diag that lays it out.
Error::ack once you are done: it throws an Error::Bail if anything went wrong.
| struct fe::Error::Note |
| struct fe::Error::Msg |
| using fe::Error::Tag = Diag::Tag |
|
inlineexplicit |
A sink of your own; Driver::error is the one every frontend building block already reports to.
driver's SrcMap and Error::msg renders through Diag::render, so driver must outlive this Error. Definition at line 72 of file error.h.
Referenced by error(), msg(), msg(), note(), note(), operator<<, and warn().
|
inline |
If errors occurred, Error::bail; otherwise Error::report any warnings to os.
Definition at line 158 of file error.h.
References bail(), num_errors(), and report().
|
inline |
Claims everything collected so far and throws it as a Bail rendered for os.
Definition at line 151 of file error.h.
References fe::Error::Bail::Bail(), bail(), clear(), num_errors(), num_warnings(), and str().
Referenced by ack(), bail(), and fe::Error::Bail::operator<<.
|
inline |
|
inline |
|
inline |
Definition at line 103 of file error.h.
References Error(), and msg().
Referenced by fe::Driver::error(), fe::Parser< Tok, Tag, K, S >::error(), and fe::Parser< Tok, Tag, K, S >::error().
Records the message fmt renders; see Diag::render. tag must be Tag::Error or Tag::Warn - a Tag::Note belongs to Error::note.
Definition at line 91 of file error.h.
References Error().
Referenced by error(), operator<<, and warn().
|
inline |
s more than once. Definition at line 98 of file error.h.
References Error().
|
inline |
A Note that points elsewhere; dropped when loc adds nothing.
A loc overlapping the primary one is already covered by its snippet and so points nowhere new. An invalid loc points nowhere and degrades to the = note: continuation above. The renderer gives loc a header line of its own, so phrase the message to stand alone.
Definition at line 116 of file error.h.
References Error().
|
inline |
A = note: continuation of the diagnostic being built; it has no Loc of its own to point at.
Definition at line 107 of file error.h.
References Error(), and fe::Loc::Loc().
Referenced by fe::Driver::note(), fe::Driver::note(), and operator<<.
|
inline |
|
inline |
Definition at line 81 of file error.h.
Referenced by bail(), and operator<<.
|
inline |
Nothing recorded that must stop the compilation?
Definition at line 79 of file error.h.
References num_errors().
|
inline |
|
inline |
Renders everything collected so far the way it would appear on os; os only decides the coloring.
Definition at line 134 of file error.h.
References fe::term::Always, fe::term::Never, and fe::term::use_color().
Referenced by bail(), and operator<<.
|
inline |
Did Diag::max_errors drop anything?
|
inline |
Definition at line 104 of file error.h.
References Error(), and msg().
Referenced by fe::Driver::warn().
|
friend |
Hands every Msg, its Notes, and the closing summary to Diag.
Definition at line 165 of file error.h.
References Error(), msg(), note(), num_errors(), num_warnings(), str(), and fe::Diag::summary().