Skip to content

Commit bc30c3f

Browse files
committed
refactor: rename UpperCamelCase -> lower_snake_case
Change the name of non-type template parameters to match the style described in ADR018.
1 parent c780347 commit bc30c3f

File tree

7 files changed

+60
-62
lines changed

7 files changed

+60
-62
lines changed

src/quick-lint-js/container/linked-bump-allocator.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ namespace quick_lint_js {
3333
// * all allocations have the same alignment
3434
//
3535
// Internally, Linked_Bump_Allocator maintains a linked list of chunks.
36-
template <std::size_t Alignment>
36+
template <std::size_t alignment>
3737
class Linked_Bump_Allocator : public Memory_Resource {
3838
private:
3939
struct Chunk_Header;
4040

4141
public:
42-
static inline constexpr std::size_t alignment = Alignment;
43-
4442
explicit Linked_Bump_Allocator(const char* debug_owner) {
4543
static_cast<void>(debug_owner);
4644
}
@@ -134,7 +132,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
134132

135133
template <class T, class... Args>
136134
T* new_object(Args&&... args) {
137-
static_assert(alignof(T) <= Alignment,
135+
static_assert(alignof(T) <= alignment,
138136
"T is not allowed by this allocator; this allocator's "
139137
"alignment is insufficient for T");
140138
constexpr std::size_t byte_size = align_up(sizeof(T));
@@ -143,7 +141,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
143141

144142
template <class T>
145143
[[nodiscard]] T* allocate_uninitialized_array(std::size_t size) {
146-
static_assert(alignof(T) <= Alignment,
144+
static_assert(alignof(T) <= alignment,
147145
"T is not allowed by this allocator; this allocator's "
148146
"alignment is insufficient for T");
149147
std::size_t byte_size = this->align_up(size * sizeof(T));
@@ -206,12 +204,12 @@ class Linked_Bump_Allocator : public Memory_Resource {
206204

207205
protected:
208206
void* do_allocate(std::size_t bytes, std::size_t align) override {
209-
QLJS_ASSERT(align <= Alignment);
207+
QLJS_ASSERT(align <= alignment);
210208
return this->allocate_bytes(this->align_up(bytes));
211209
}
212210

213211
void do_deallocate(void* p, std::size_t bytes, std::size_t align) override {
214-
QLJS_ASSERT(align <= Alignment);
212+
QLJS_ASSERT(align <= alignment);
215213
this->deallocate_bytes(p, bytes);
216214
}
217215

@@ -220,7 +218,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
220218
}
221219

222220
private:
223-
struct alignas(maximum(Alignment, alignof(void*))) Chunk_Header {
221+
struct alignas(maximum(alignment, alignof(void*))) Chunk_Header {
224222
Chunk_Header* previous; // Linked list.
225223
std::size_t size; // Size of the data portion in bytes.
226224

@@ -234,7 +232,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
234232
}
235233

236234
static std::align_val_t allocation_alignment() noexcept {
237-
return std::align_val_t{maximum(Alignment, alignof(Chunk_Header))};
235+
return std::align_val_t{maximum(alignment, alignof(Chunk_Header))};
238236
}
239237

240238
static Chunk_Header* new_chunk(std::size_t size, Chunk_Header* previous) {
@@ -243,7 +241,7 @@ class Linked_Bump_Allocator : public Memory_Resource {
243241
::operator new(allocation_size(size), allocation_alignment());
244242
#else
245243
void* chunk = ::operator new(allocation_size(size));
246-
QLJS_ASSERT(is_aligned(chunk, Alignment));
244+
QLJS_ASSERT(is_aligned(chunk, alignment));
247245
#endif
248246
return new (chunk) Chunk_Header{
249247
.previous = previous,
@@ -266,12 +264,12 @@ class Linked_Bump_Allocator : public Memory_Resource {
266264
4096 - sizeof(Chunk_Header);
267265

268266
static constexpr std::size_t align_up(std::size_t size) noexcept {
269-
return (size + Alignment - 1) & ~(Alignment - 1);
267+
return (size + alignment - 1) & ~(alignment - 1);
270268
}
271269

272270
[[nodiscard]] void* allocate_bytes(std::size_t size) {
273271
this->assert_not_disabled();
274-
QLJS_SLOW_ASSERT(size % Alignment == 0);
272+
QLJS_SLOW_ASSERT(size % alignment == 0);
275273
if (this->remaining_bytes_in_current_chunk() < size) {
276274
this->append_chunk(maximum(size, this->default_chunk_size));
277275
QLJS_ASSERT(this->remaining_bytes_in_current_chunk() >= size);

src/quick-lint-js/container/variant.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ const T& get(const Variant<Ts...>& v) noexcept {
4646
return v.template get<T>();
4747
}
4848

49-
template <std::size_t Index, class... Ts>
49+
template <std::size_t index, class... Ts>
5050
auto& get(Variant<Ts...>& v) noexcept {
51-
return v.template get<Index>();
51+
return v.template get<index>();
5252
}
5353

54-
template <std::size_t Index, class... Ts>
54+
template <std::size_t index, class... Ts>
5555
auto&& get(Variant<Ts...>&& v) noexcept {
56-
return std::move(v).template get<Index>();
56+
return std::move(v).template get<index>();
5757
}
5858

59-
template <std::size_t Index, class... Ts>
59+
template <std::size_t index, class... Ts>
6060
const auto& get(const Variant<Ts...>& v) noexcept {
61-
return v.template get<Index>();
61+
return v.template get<index>();
6262
}
6363

6464
template <class Visitor, class... Ts>
@@ -87,14 +87,14 @@ auto visit(Visitor&& f, const Variant<Ts...>& v) {
8787
return const_cast<Variant*>(this)->template get<T>(); \
8888
} \
8989
\
90-
template <std::size_t Index> \
90+
template <std::size_t index> \
9191
auto&& get() && noexcept { \
92-
return std::move(this->template get<Index>()); \
92+
return std::move(this->template get<index>()); \
9393
} \
9494
\
95-
template <std::size_t Index> \
95+
template <std::size_t index> \
9696
const auto& get() const& noexcept { \
97-
return const_cast<Variant*>(this)->template get<Index>(); \
97+
return const_cast<Variant*>(this)->template get<index>(); \
9898
} \
9999
\
100100
friend bool operator!=(const Variant& lhs, const Variant& rhs) noexcept { \
@@ -152,9 +152,9 @@ class Variant<T0> {
152152
return this->data_0_;
153153
}
154154

155-
template <std::size_t Index>
155+
template <std::size_t index>
156156
T0& get() & noexcept {
157-
static_assert(Index == 0, "unexpected Index");
157+
static_assert(index == 0, "unexpected Index");
158158
return this->data_0_;
159159
}
160160

@@ -278,16 +278,16 @@ class Variant<T0, T1> {
278278
}
279279
}
280280

281-
template <std::size_t Index>
281+
template <std::size_t index>
282282
auto& get() & noexcept {
283-
if constexpr (Index == 0) {
283+
if constexpr (index == 0) {
284284
QLJS_ASSERT(this->tag_ == 0);
285285
return this->data_0_;
286-
} else if constexpr (Index == 1) {
286+
} else if constexpr (index == 1) {
287287
QLJS_ASSERT(this->tag_ == 1);
288288
return this->data_1_;
289289
} else {
290-
static_assert(Index == 0, "unexpected Index");
290+
static_assert(index == 0, "unexpected Index");
291291
}
292292
}
293293

@@ -486,19 +486,19 @@ class Variant<T0, T1, T2> {
486486
}
487487
}
488488

489-
template <std::size_t Index>
489+
template <std::size_t index>
490490
auto& get() & noexcept {
491-
if constexpr (Index == 0) {
491+
if constexpr (index == 0) {
492492
QLJS_ASSERT(this->tag_ == 0);
493493
return this->data_0_;
494-
} else if constexpr (Index == 1) {
494+
} else if constexpr (index == 1) {
495495
QLJS_ASSERT(this->tag_ == 1);
496496
return this->data_1_;
497-
} else if constexpr (Index == 2) {
497+
} else if constexpr (index == 2) {
498498
QLJS_ASSERT(this->tag_ == 2);
499499
return this->data_2_;
500500
} else {
501-
static_assert(Index == 0, "unexpected Index");
501+
static_assert(index == 0, "unexpected Index");
502502
}
503503
}
504504

src/quick-lint-js/debug/mongoose.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ class Mongoose_Mgr {
4040
::mg_mgr mgr_;
4141
};
4242

43-
template <auto MemberFunctionPointer>
43+
template <auto member_function_pointer>
4444
mg_event_handler_t mongoose_callback() {
4545
using Self = typename Member_Function_Pointer_Traits<decltype(
46-
MemberFunctionPointer)>::Class_Type;
46+
member_function_pointer)>::Class_Type;
4747
return [](::mg_connection *c, int ev, void *ev_data, void *fn_data) -> void {
48-
(static_cast<Self *>(fn_data)->*MemberFunctionPointer)(c, ev, ev_data);
48+
(static_cast<Self *>(fn_data)->*member_function_pointer)(c, ev, ev_data);
4949
};
5050
}
5151
}

src/quick-lint-js/fe/expression.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ class Expression_Arena {
179179
template <class T>
180180
Array_Ptr<T> make_array(T *begin, T *end);
181181

182-
template <class T, std::size_t Size>
183-
Array_Ptr<T> make_array(std::array<T, Size> &&);
182+
template <class T, std::size_t size>
183+
Array_Ptr<T> make_array(std::array<T, size> &&);
184184

185185
Monotonic_Allocator *allocator() noexcept { return &this->allocator_; }
186186

@@ -335,9 +335,9 @@ inline Expression_Arena::Array_Ptr<T> Expression_Arena::make_array(T *begin,
335335
return Array_Ptr<T>(result_begin, size);
336336
}
337337

338-
template <class T, std::size_t Size>
338+
template <class T, std::size_t size>
339339
inline Expression_Arena::Array_Ptr<T> Expression_Arena::make_array(
340-
std::array<T, Size> &&elements) {
340+
std::array<T, size> &&elements) {
341341
return this->make_array(elements.data(), elements.data() + elements.size());
342342
}
343343

src/quick-lint-js/fe/parse.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class Parser {
447447
void parse_and_visit_with(Parse_Visitor_Base &v);
448448

449449
template <class Expected_Parentheses_Error, class Expected_Parenthesis_Error,
450-
bool CheckForSketchyConditions, bool CheckForCommaOperator>
450+
bool check_for_sketchy_conditions, bool check_for_comma_operator>
451451
void parse_and_visit_parenthesized_expression(Parse_Visitor_Base &v,
452452
Source_Code_Span token);
453453

@@ -1079,7 +1079,7 @@ class Parser {
10791079
};
10801080

10811081
template <class Expected_Parentheses_Error, class Expected_Parenthesis_Error,
1082-
bool CheckForSketchyConditions, bool CheckForCommaOperator>
1082+
bool check_for_sketchy_conditions, bool check_for_comma_operator>
10831083
void Parser::parse_and_visit_parenthesized_expression(
10841084
Parse_Visitor_Base &v, Source_Code_Span token_span) {
10851085
bool have_expression_left_paren = this->peek().type == Token_Type::left_paren;
@@ -1100,11 +1100,11 @@ void Parser::parse_and_visit_parenthesized_expression(
11001100
Expression *ast = this->parse_expression(v);
11011101
this->visit_expression(ast, v, Variable_Context::rhs);
11021102

1103-
if constexpr (CheckForSketchyConditions) {
1103+
if constexpr (check_for_sketchy_conditions) {
11041104
this->error_on_sketchy_condition(ast);
11051105
}
11061106

1107-
if constexpr (CheckForCommaOperator) {
1107+
if constexpr (check_for_comma_operator) {
11081108
this->warn_on_comma_operator_in_conditional_statement(ast);
11091109
}
11101110

src/quick-lint-js/port/span.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class Span {
2828

2929
explicit Span() noexcept : data_(nullptr), size_(0) {}
3030

31-
template <std::size_t N>
32-
explicit Span(const std::array<std::remove_const_t<T>, N> &data) noexcept
33-
: data_(data.data()), size_(N) {}
31+
template <std::size_t n>
32+
explicit Span(const std::array<std::remove_const_t<T>, n> &data) noexcept
33+
: data_(data.data()), size_(n) {}
3434

35-
template <std::size_t N>
36-
explicit Span(T (&data)[N]) noexcept : data_(data), size_(N) {}
35+
template <std::size_t n>
36+
explicit Span(T (&data)[n]) noexcept : data_(data), size_(n) {}
3737

3838
explicit Span(const std::vector<std::remove_const_t<T>> &data) noexcept
3939
: data_(data.data()), size_(narrow_cast<Span_Size>(data.size())) {}

test/quick-lint-js/array.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ inline constexpr auto make_array_explicit(Args&&... items) {
2525
return std::array<T, sizeof...(items)>{T(std::forward<Args>(items))...};
2626
}
2727

28-
template <class T, std::size_t LHSSize, std::size_t RHSSize,
29-
std::size_t... LHSIndexes, std::size_t... RHSIndexes>
30-
inline constexpr std::array<T, LHSSize + RHSSize> concat_impl(
31-
const std::array<T, LHSSize>& lhs, std::index_sequence<LHSIndexes...>,
32-
const std::array<T, RHSSize>& rhs, std::index_sequence<RHSIndexes...>) {
33-
return std::array<T, LHSSize + RHSSize>{lhs[LHSIndexes]...,
34-
rhs[RHSIndexes]...};
28+
template <class T, std::size_t lhs_size, std::size_t rhs_size,
29+
std::size_t... lhs_indexes, std::size_t... rhs_indexes>
30+
inline constexpr std::array<T, lhs_size + rhs_size> concat_impl(
31+
const std::array<T, lhs_size>& lhs, std::index_sequence<lhs_indexes...>,
32+
const std::array<T, rhs_size>& rhs, std::index_sequence<rhs_indexes...>) {
33+
return std::array<T, lhs_size + rhs_size>{lhs[lhs_indexes]...,
34+
rhs[rhs_indexes]...};
3535
}
3636

37-
template <class T, std::size_t LHSSize, std::size_t RHSSize>
38-
inline constexpr std::array<T, LHSSize + RHSSize> concat(
39-
const std::array<T, LHSSize>& lhs, const std::array<T, RHSSize>& rhs) {
40-
return concat_impl<T, LHSSize, RHSSize>(
41-
lhs, std::make_index_sequence<LHSSize>(), rhs,
42-
std::make_index_sequence<RHSSize>());
37+
template <class T, std::size_t lhs_size, std::size_t rhs_size>
38+
inline constexpr std::array<T, lhs_size + rhs_size> concat(
39+
const std::array<T, lhs_size>& lhs, const std::array<T, rhs_size>& rhs) {
40+
return concat_impl<T, lhs_size, rhs_size>(
41+
lhs, std::make_index_sequence<lhs_size>(), rhs,
42+
std::make_index_sequence<rhs_size>());
4343
}
4444

4545
QLJS_WARNING_POP

0 commit comments

Comments
 (0)