Skip to content

Commit aa4de15

Browse files
committed
refactor: rename QLJS_ERROR_TYPE -> QLJS_DIAG_TYPE
1 parent c5e8871 commit aa4de15

File tree

9 files changed

+289
-289
lines changed

9 files changed

+289
-289
lines changed

src/buffering-error-reporter.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ struct buffering_error_reporter::impl {
2121
union underlying_error {
2222
explicit underlying_error() noexcept {}
2323

24-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format) \
24+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format) \
2525
::quick_lint_js::name name; \
2626
static_assert(std::is_trivially_copyable_v<::quick_lint_js::name>, \
2727
#name " should be trivially copyable");
28-
QLJS_X_ERROR_TYPES
29-
#undef QLJS_ERROR_TYPE
28+
QLJS_X_DIAG_TYPES
29+
#undef QLJS_DIAG_TYPE
3030
};
3131

3232
error_type type;
@@ -58,10 +58,10 @@ buffering_error_reporter::~buffering_error_reporter() = default;
5858

5959
void buffering_error_reporter::report_impl(error_type type, void *error) {
6060
static constexpr unsigned char error_sizes[] = {
61-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format) \
61+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format) \
6262
sizeof(::quick_lint_js::name),
63-
QLJS_X_ERROR_TYPES
64-
#undef QLJS_ERROR_TYPE
63+
QLJS_X_DIAG_TYPES
64+
#undef QLJS_DIAG_TYPE
6565
};
6666

6767
impl::any_error &e = this->impl_->errors_.emplace_back();

src/diagnostic.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ std::array<char, 5> error_code_to_string(std::uint16_t error_code) noexcept {
5757
};
5858
}
5959

60-
// Convert a QLJS_ERROR_TYPE user into a diagnostic_info.
60+
// Convert a QLJS_DIAG_TYPE user into a diagnostic_info.
6161
template <class Error>
6262
class diagnostic_info_builder {
6363
public:
@@ -143,7 +143,7 @@ struct diagnostic_info_for_error;
143143
#define MESSAGE(message_format, ...) \
144144
.add(message_format, MAKE_ARGS(__VA_ARGS__))
145145

146-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
146+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
147147
template <> \
148148
struct diagnostic_info_for_error<name> { \
149149
using error_class = name; \
@@ -153,16 +153,16 @@ struct diagnostic_info_for_error;
153153
format_call.build(); \
154154
} \
155155
};
156-
QLJS_X_ERROR_TYPES
157-
#undef QLJS_ERROR_TYPE
156+
QLJS_X_DIAG_TYPES
157+
#undef QLJS_DIAG_TYPE
158158
}
159159

160160
DIAGNOSTIC_CONSTEXPR_IF_POSSIBLE const diagnostic_info
161161
all_diagnostic_infos[] = {
162-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
162+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
163163
diagnostic_info_for_error<name>::get(),
164-
QLJS_X_ERROR_TYPES
165-
#undef QLJS_ERROR_TYPE
164+
QLJS_X_DIAG_TYPES
165+
#undef QLJS_DIAG_TYPE
166166
};
167167

168168
const diagnostic_info& get_diagnostic_info(error_type type) noexcept {

src/error-debug.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
namespace quick_lint_js {
99
std::ostream& operator<<(std::ostream& out, error_type type) {
1010
switch (type) {
11-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
12-
case error_type::name: \
11+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
12+
case error_type::name: \
1313
return out << #name;
14-
QLJS_X_ERROR_TYPES
15-
#undef QLJS_ERROR_TYPE
14+
QLJS_X_DIAG_TYPES
15+
#undef QLJS_DIAG_TYPE
1616
}
1717
QLJS_UNREACHABLE();
1818
}

src/quick-lint-js/error-reporter.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class error_reporter {
1919

2020
virtual ~error_reporter() = default;
2121

22-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format) \
23-
void report(name error) { \
24-
this->report_impl(error_type_from_type<name>, &error); \
22+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format) \
23+
void report(name error) { \
24+
this->report_impl(error_type_from_type<name>, &error); \
2525
}
26-
QLJS_X_ERROR_TYPES
27-
#undef QLJS_ERROR_TYPE
26+
QLJS_X_DIAG_TYPES
27+
#undef QLJS_DIAG_TYPE
2828

2929
virtual void report_impl(error_type type, void *error) = 0;
3030
};

src/quick-lint-js/error.h

Lines changed: 230 additions & 230 deletions
Large diffs are not rendered by default.

test/error-collector.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@
99
namespace quick_lint_js {
1010
void error_collector::report_impl(error_type type, void *error) {
1111
switch (type) {
12-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
13-
case error_type::name: \
14-
this->errors.emplace_back(*reinterpret_cast<const name *>(error)); \
12+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
13+
case error_type::name: \
14+
this->errors.emplace_back(*reinterpret_cast<const name *>(error)); \
1515
break;
16-
QLJS_X_ERROR_TYPES
17-
#undef QLJS_ERROR_TYPE
16+
QLJS_X_DIAG_TYPES
17+
#undef QLJS_DIAG_TYPE
1818
}
1919
}
2020

21-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
22-
error_collector::error::error(const name &data) \
21+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
22+
error_collector::error::error(const name &data) \
2323
: type_(error_type::name), variant_##name##_(std::move(data)) {}
24-
QLJS_X_ERROR_TYPES
25-
#undef QLJS_ERROR_TYPE
24+
QLJS_X_DIAG_TYPES
25+
#undef QLJS_DIAG_TYPE
2626

2727
error_type error_collector::error::type() const noexcept { return this->type_; }
2828

2929
const char *error_collector::error::error_code() const noexcept {
3030
switch (this->type_) {
31-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
32-
case error_type::name: \
31+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
32+
case error_type::name: \
3333
return code;
34-
QLJS_X_ERROR_TYPES
35-
#undef QLJS_ERROR_TYPE
34+
QLJS_X_DIAG_TYPES
35+
#undef QLJS_DIAG_TYPE
3636
}
3737
QLJS_UNREACHABLE();
3838
}
@@ -41,7 +41,7 @@ const void *error_collector::error::data() const noexcept {
4141
return &this->variant_diag_unexpected_token_; // Arbitrary member.
4242
}
4343

44-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
44+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
4545
template <> \
4646
bool holds_alternative<name>(const error_collector::error &e) noexcept { \
4747
return e.type_ == error_type::name; \
@@ -52,17 +52,17 @@ const void *error_collector::error::data() const noexcept {
5252
QLJS_ASSERT(holds_alternative<name>(e)); \
5353
return e.variant_##name##_; \
5454
}
55-
QLJS_X_ERROR_TYPES
56-
#undef QLJS_ERROR_TYPE
55+
QLJS_X_DIAG_TYPES
56+
#undef QLJS_DIAG_TYPE
5757

5858
void PrintTo(const error_collector::error &e, std::ostream *out) {
5959
*out << e.type_;
6060
}
6161

62-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
62+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
6363
void PrintTo(const name &, std::ostream *out) { *out << #name; }
64-
QLJS_X_ERROR_TYPES
65-
#undef QLJS_ERROR_TYPE
64+
QLJS_X_DIAG_TYPES
65+
#undef QLJS_DIAG_TYPE
6666
}
6767

6868
// quick-lint-js finds bugs in JavaScript programs.

test/quick-lint-js/error-collector.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ struct error_collector : public error_reporter {
2020
// Like std::variant<(error types)>, but with much faster compilation.
2121
class error {
2222
public:
23-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
23+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
2424
explicit error(const name &);
25-
QLJS_X_ERROR_TYPES
26-
#undef QLJS_ERROR_TYPE
25+
QLJS_X_DIAG_TYPES
26+
#undef QLJS_DIAG_TYPE
2727

2828
error_type type() const noexcept;
2929
const char *error_code() const noexcept;
@@ -40,10 +40,10 @@ struct error_collector : public error_reporter {
4040
private:
4141
error_type type_;
4242
union {
43-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
43+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
4444
name variant_##name##_;
45-
QLJS_X_ERROR_TYPES
46-
#undef QLJS_ERROR_TYPE
45+
QLJS_X_DIAG_TYPES
46+
#undef QLJS_DIAG_TYPE
4747
};
4848
};
4949

@@ -58,10 +58,10 @@ bool holds_alternative(const error_collector::error &) noexcept;
5858

5959
void PrintTo(const error_collector::error &, std::ostream *);
6060

61-
#define QLJS_ERROR_TYPE(name, code, severity, struct_body, format_call) \
61+
#define QLJS_DIAG_TYPE(name, code, severity, struct_body, format_call) \
6262
void PrintTo(const name &, std::ostream *);
63-
QLJS_X_ERROR_TYPES
64-
#undef QLJS_ERROR_TYPE
63+
QLJS_X_DIAG_TYPES
64+
#undef QLJS_DIAG_TYPE
6565
}
6666

6767
#endif

test/test-error-list.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ namespace quick_lint_js {
1717
namespace {
1818
TEST(test_error_list, compiled_default_matches_all_errors) {
1919
compiled_error_list errors;
20-
#define QLJS_ERROR_TYPE(error_name, error_code, severity, struct_body, format) \
20+
#define QLJS_DIAG_TYPE(error_name, error_code, severity, struct_body, format) \
2121
EXPECT_TRUE(errors.is_present(error_type::error_name)) << #error_name;
22-
QLJS_X_ERROR_TYPES
23-
#undef QLJS_ERROR_TYPE
22+
QLJS_X_DIAG_TYPES
23+
#undef QLJS_DIAG_TYPE
2424

2525
EXPECT_THAT(errors.parse_errors("--testoption"), IsEmpty());
2626
EXPECT_THAT(errors.parse_warnings(), IsEmpty());
@@ -76,10 +76,10 @@ TEST(test_error_list, compiled_exclude_all_matches_no_errors) {
7676
compiled_error_list errors;
7777
errors.add(parsed_errors);
7878

79-
#define QLJS_ERROR_TYPE(error_name, error_code, severity, struct_body, format) \
79+
#define QLJS_DIAG_TYPE(error_name, error_code, severity, struct_body, format) \
8080
EXPECT_FALSE(errors.is_present(error_type::error_name)) << #error_name;
81-
QLJS_X_ERROR_TYPES
82-
#undef QLJS_ERROR_TYPE
81+
QLJS_X_DIAG_TYPES
82+
#undef QLJS_DIAG_TYPE
8383

8484
EXPECT_THAT(errors.parse_errors("--testoption"), IsEmpty());
8585
EXPECT_THAT(errors.parse_warnings(), IsEmpty());

test/test-error.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ struct error_name_and_code {
1414
const char* code;
1515
};
1616
static constexpr error_name_and_code all_errors[] = {
17-
#define QLJS_ERROR_TYPE(error_name, error_code, severity, struct_body, format) \
17+
#define QLJS_DIAG_TYPE(error_name, error_code, severity, struct_body, format) \
1818
{.name = #error_name, .code = error_code},
19-
QLJS_X_ERROR_TYPES
20-
#undef QLJS_ERROR_TYPE
19+
QLJS_X_DIAG_TYPES
20+
#undef QLJS_DIAG_TYPE
2121
};
2222

2323
std::string next_unused_error_code() {

0 commit comments

Comments
 (0)