22#include "lib/compile_context.h"
23#include "lib/cstring.h"
24#include "lib/error_reporter.h"
35inline unsigned diagnosticCount() {
46template <
typename... Args>
47inline void error(
const char *format, Args &&...args) {
49 auto action = context.getDefaultErrorDiagnosticAction();
50 context.errorReporter().diagnose(action,
nullptr, format,
"", std::forward<Args>(args)...);
56template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
57void error(
const int kind,
const char *format,
const T *node, Args &&...args) {
59 auto action = context.getDefaultErrorDiagnosticAction();
60 context.errorReporter().diagnose(action, kind, format,
"", node, std::forward<Args>(args)...);
64template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
65void errorWithSuffix(
const int kind,
const char *format,
const char *suffix,
const T *node,
68 auto action = context.getDefaultErrorDiagnosticAction();
69 context.errorReporter().diagnose(action, kind, format, suffix, node,
70 std::forward<Args>(args)...);
74template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
75void error(
const int kind,
const char *format,
const T &node, Args &&...args) {
76 error(kind, format, &node, std::forward<Args>(args)...);
84template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
85void error(
const char *format,
const T *node, Args &&...args) {
86 error(ErrorType::LEGACY_ERROR, format, node, std::forward<Args>(args)...);
91template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
92void error(
const char *format,
const T &node, Args &&...args) {
93 error(ErrorType::LEGACY_ERROR, format, node, std::forward<Args>(args)...);
99template <
typename... Args>
100void error(
const int kind,
const char *format, Args &&...args) {
102 auto action = context.getDefaultErrorDiagnosticAction();
103 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
108template <
typename... Args>
109inline void warning(
const char *format, Args &&...args) {
111 auto action = context.getDefaultWarningDiagnosticAction();
112 context.errorReporter().diagnose(action,
nullptr, format,
"", std::forward<Args>(args)...);
117template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
118void warning(
const int kind,
const char *format,
const T *node, Args &&...args) {
120 auto action = context.getDefaultWarningDiagnosticAction();
121 context.errorReporter().diagnose(action, kind, format,
"", node, std::forward<Args>(args)...);
125template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
126void warning(
const int kind,
const char *format,
const T &node, Args &&...args) {
127 ::warning(kind, format, &node, std::forward<Args>(args)...);
132template <
typename... Args>
133void warning(
const int kind,
const char *format, Args &&...args) {
135 auto action = context.getDefaultWarningDiagnosticAction();
136 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
140template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
141void info(
const int kind,
const char *format,
const T *node, Args &&...args) {
143 auto action = context.getDefaultInfoDiagnosticAction();
144 context.errorReporter().diagnose(action, kind, format,
"", node, std::forward<Args>(args)...);
148template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
149void info(
const int kind,
const char *format,
const T &node, Args &&...args) {
150 ::info(kind, format, &node, std::forward<Args>(args)...);
155template <
typename... Args>
156void info(
const int kind,
const char *format, Args &&...args) {
158 auto action = context.getDefaultInfoDiagnosticAction();
159 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
175template <
typename... Args>
176inline void diagnose(DiagnosticAction defaultAction,
const char *diagnosticName,
const char *format,
177 const char *suffix, Args &&...args) {
179 auto action = context.getDiagnosticAction(
cstring(diagnosticName), defaultAction);
180 context.errorReporter().diagnose(action, diagnosticName, format, suffix,
181 std::forward<Args>(args)...);
static BaseCompileContext & get()
Definition compile_context.cpp:59
virtual ErrorReporter & errorReporter()
Definition compile_context.cpp:63
unsigned getDiagnosticCount() const
Definition error_reporter.h:183