24#include "lib/compile_context.h"
25#include "lib/cstring.h"
26#include "lib/error_reporter.h"
50template <
typename... Args>
51inline void error(
const char *format, Args &&...args) {
53 auto action = context.getDefaultErrorDiagnosticAction();
54 context.errorReporter().diagnose(action,
nullptr, format,
"", std::forward<Args>(args)...);
60template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
61void error(
const int kind,
const char *format,
const T *node, Args &&...args) {
63 auto action = context.getDefaultErrorDiagnosticAction();
64 context.errorReporter().diagnose(action, kind, format,
"", node, std::forward<Args>(args)...);
68template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
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,
74 std::forward<Args>(args)...);
78template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_po
inter_v<T>>,
80void error(
const int kind,
const char *format,
const T &node, Args &&...args) {
81 error(kind, format, &node, std::forward<Args>(args)...);
89template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
90void error(
const char *format,
const T *node, Args &&...args) {
91 error(ErrorType::LEGACY_ERROR, format, node, std::forward<Args>(args)...);
96template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_po
inter_v<T>>,
98void error(
const char *format,
const T &node, Args &&...args) {
99 error(ErrorType::LEGACY_ERROR, format, node, std::forward<Args>(args)...);
105template <
typename... Args>
106void error(
const int kind,
const char *format, Args &&...args) {
108 auto action = context.getDefaultErrorDiagnosticAction();
109 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
114template <
typename... Args>
115inline void warning(
const char *format, Args &&...args) {
117 auto action = context.getDefaultWarningDiagnosticAction();
118 context.errorReporter().diagnose(action,
nullptr, format,
"", std::forward<Args>(args)...);
123template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
124void warning(
const int kind,
const char *format,
const T *node, Args &&...args) {
126 auto action = context.getDefaultWarningDiagnosticAction();
127 context.errorReporter().diagnose(action, kind, format,
"", node, std::forward<Args>(args)...);
131template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_po
inter_v<T>>,
133void warning(
const int kind,
const char *format,
const T &node, Args &&...args) {
134 ::P4::warning(kind, format, &node, std::forward<Args>(args)...);
139template <
typename... Args>
140void warning(
const int kind,
const char *format, Args &&...args) {
142 auto action = context.getDefaultWarningDiagnosticAction();
143 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
147template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T>>,
class... Args>
148void info(
const int kind,
const char *format,
const T *node, Args &&...args) {
150 auto action = context.getDefaultInfoDiagnosticAction();
151 context.errorReporter().diagnose(action, kind, format,
"", node, std::forward<Args>(args)...);
155template <
class T,
typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_po
inter_v<T>>,
157void info(
const int kind,
const char *format,
const T &node, Args &&...args) {
158 ::P4::info(kind, format, &node, std::forward<Args>(args)...);
163template <
typename... Args>
164void info(
const int kind,
const char *format, Args &&...args) {
166 auto action = context.getDefaultInfoDiagnosticAction();
167 context.errorReporter().diagnose(action, kind, format,
"", std::forward<Args>(args)...);
virtual ErrorReporter & errorReporter()
Definition compile_context.cpp:65
static BaseCompileContext & get()
Definition compile_context.cpp:61
unsigned getDiagnosticCount() const
Definition error_reporter.h:185
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
void warning(const char *format, Args &&...args)
Report a warning with the given message.
Definition lib/error.h:115
unsigned diagnosticCount()
Definition lib/error.h:39
void errorWithSuffix(const int kind, const char *format, const char *suffix, const T *node, Args &&...args)
This is similar to the above method, but also has a suffix.
Definition lib/error.h:69
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:51
void info(const int kind, const char *format, const T *node, Args &&...args)
Report info messages of type kind. Requires that the node argument have source info.
Definition lib/error.h:148
unsigned errorCount()
Definition lib/error.h:35