Skip to content

Commit fabcc1d

Browse files
committed
Refactor: use MESSAGE instead of ERROR/WARNING/NOTE
Make writing diagnostics less error-prone by replacing the three message macros (ERROR, WARNING, and NOTE) with one: MESSAGE. This commit should not change behavior.
1 parent e471f73 commit fabcc1d

File tree

2 files changed

+500
-491
lines changed

2 files changed

+500
-491
lines changed

src/diagnostic.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,8 @@ class diagnostic_info_builder {
4848

4949
// Each of Args must be a diagnostic_message_arg_info.
5050
template <class... Args>
51-
constexpr diagnostic_info_builder add(diagnostic_severity sev,
52-
const translatable_message& message,
51+
constexpr diagnostic_info_builder add(const translatable_message& message,
5352
const Args&... arg_infos) {
54-
if (this->current_message_index_ == 0) {
55-
if (sev != this->info_.severity) {
56-
#if __cpp_constexpr >= 201907L && !defined(_MSC_VER)
57-
// If you see an error with the following line, error.h contains a
58-
// QLJS_ERROR_TYPE call with inconsistent diagnostic severities.
59-
asm("");
60-
#endif
61-
}
62-
}
63-
6453
diagnostic_message_info& message_info =
6554
this->info_.messages[this->current_message_index_++];
6655
message_info.format = message;
@@ -128,12 +117,8 @@ struct diagnostic_info_for_error;
128117
#define MAKE_ARGS_2(arg0, arg1) MAKE_ARGS_1(arg0), MAKE_ARGS_1(arg1)
129118
#define MAKE_ARGS_3(arg0, arg1, arg2) MAKE_ARGS_2(arg0, arg1), MAKE_ARGS_1(arg2)
130119

131-
#define ERROR(message_format, ...) \
132-
.add(diagnostic_severity::error, message_format, MAKE_ARGS(__VA_ARGS__))
133-
#define WARNING(message_format, ...) \
134-
.add(diagnostic_severity::warning, message_format, MAKE_ARGS(__VA_ARGS__))
135-
#define NOTE(message_format, ...) \
136-
.add(diagnostic_severity::note, message_format, MAKE_ARGS(__VA_ARGS__))
120+
#define MESSAGE(message_format, ...) \
121+
.add(message_format, MAKE_ARGS(__VA_ARGS__))
137122

138123
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
139124
template <> \

0 commit comments

Comments
 (0)