22#include "lib/compile_context.h"
23#include "lib/cstring.h"
24#include "lib/error_reporter.h"
35inline unsigned diagnosticCount() {
46template <
typename... T>
47inline void error(
const char *format, T... args) {
49 auto action = context.getDefaultErrorDiagnosticAction();
50 context.errorReporter().diagnose(action,
nullptr, format,
"", args...);
57 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
59void error(
const int kind,
const char *format,
const T *node, Args... args) {
61 auto action = context.getDefaultErrorDiagnosticAction();
62 context.errorReporter().diagnose(action, kind, format,
"", node, args...);
67 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
69void errorWithSuffix(
const int kind,
const char *format,
const char *suffix,
const T *node,
72 auto action = context.getDefaultErrorDiagnosticAction();
73 context.errorReporter().diagnose(action, kind, format, suffix, node, args...);
78 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
80void error(
const int kind,
const char *format,
const T &node, Args... args) {
81 error(kind, format, &node, std::forward<Args>(args)...);
90 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
92void error(
const char *format,
const T *node, Args... args) {
93 error(ErrorType::LEGACY_ERROR, format, node, std::forward<Args>(args)...);
99 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
101void error(
const char *format,
const T &node, Args... args) {
102 error(ErrorType::LEGACY_ERROR, format, node, std::forward<Args>(args)...);
108template <
typename... Args>
109void error(
const int kind,
const char *format, Args... args) {
111 auto action = context.getDefaultErrorDiagnosticAction();
112 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
117template <
typename... T>
118inline void warning(
const char *format, T... args) {
120 auto action = context.getDefaultWarningDiagnosticAction();
121 context.errorReporter().diagnose(action,
nullptr, format,
"", args...);
127 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
129void warning(
const int kind,
const char *format,
const T *node, Args... args) {
131 auto action = context.getDefaultWarningDiagnosticAction();
132 context.errorReporter().diagnose(action, kind, format,
"", node, args...);
137 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
139void warning(
const int kind,
const char *format,
const T &node, Args... args) {
140 ::warning(kind, format, &node, std::forward<Args>(args)...);
145template <
typename... Args>
146void warning(
const int kind,
const char *format, Args... args) {
148 auto action = context.getDefaultWarningDiagnosticAction();
149 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
154 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
156void info(
const int kind,
const char *format,
const T *node, Args... args) {
158 auto action = context.getDefaultInfoDiagnosticAction();
159 context.errorReporter().diagnose(action, kind, format,
"", node, args...);
164 typename =
typename std::enable_if<std::is_base_of<Util::IHasSourceInfo, T>::value>::type,
166void info(
const int kind,
const char *format,
const T &node, Args... args) {
167 ::info(kind, format, &node, std::forward<Args>(args)...);
172template <
typename... Args>
173void info(
const int kind,
const char *format, Args... args) {
175 auto action = context.getDefaultInfoDiagnosticAction();
176 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
192template <
typename... T>
193inline void diagnose(DiagnosticAction defaultAction,
const char *diagnosticName,
const char *format,
194 const char *suffix, T... args) {
196 auto action = context.getDiagnosticAction(diagnosticName, defaultAction);
197 context.errorReporter().diagnose(action, diagnosticName, format, suffix, args...);
static BaseCompileContext & get()
Definition compile_context.cpp:59
virtual ErrorReporter & errorReporter()
Definition compile_context.cpp:63
unsigned getDiagnosticCount() const
Definition error_reporter.h:196