Format preprocessor diagnostics

This commit is contained in:
Jonathan Müller 2017-02-19 20:51:08 +01:00
commit f66fa70b1f
3 changed files with 106 additions and 12 deletions

View file

@ -46,7 +46,7 @@ namespace cppast
{
result += file.value() + ":";
if (line)
result += line.value() + ":";
result += std::to_string(line.value()) + ":";
if (entity)
result += " (" + entity.value() + "):";
}
@ -66,6 +66,22 @@ namespace cppast
/// \notes This will usually result in an exception being thrown after the diagnostic has been displayed.
};
/// \returns A human-readable string describing the severity.
inline const char* to_string(severity s) noexcept
{
switch (s)
{
case severity::warning:
return "warning";
case severity::error:
return "error";
case severity::critical:
return "critical";
}
return "programmer error";
}
/// A diagnostic.
///
/// It represents an error message from a [cppast::parser]().