Skip to content

Commit f1b9aea

Browse files
committed
added consts, fixed a initialization to pass clang-tidy
# Conflicts: # source/reflect.h
1 parent b652eb2 commit f1b9aea

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Checks: 'misc-*, -misc-definitions-in-headers, -misc-non-private-member-variables-in-classes, -misc-no-recursion'
1+
Checks: 'misc-*, -misc-definitions-in-headers, -misc-non-private-member-variables-in-classes, -misc-no-recursion, -misc-include-cleaner, -misc-use-anonymous-namespace'

include/cpp2util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,12 +1859,12 @@ inline constexpr auto is_narrowing_v =
18591859
// [dcl.init.list] 7.1
18601860
(std::is_floating_point_v<From> && std::is_integral_v<To>) ||
18611861
// [dcl.init.list] 7.2
1862-
(std::is_floating_point_v<From> && std::is_floating_point_v<To> && sizeof(From) > sizeof(To)) ||
1862+
(std::is_floating_point_v<From> && std::is_floating_point_v<To> && sizeof(From) > sizeof(To)) || // NOLINT(misc-redundant-expression)
18631863
// [dcl.init.list] 7.3
18641864
(std::is_integral_v<From> && std::is_floating_point_v<To>) ||
18651865
(std::is_enum_v<From> && std::is_floating_point_v<To>) ||
18661866
// [dcl.init.list] 7.4
1867-
(std::is_integral_v<From> && std::is_integral_v<To> && sizeof(From) > sizeof(To)) ||
1867+
(std::is_integral_v<From> && std::is_integral_v<To> && sizeof(From) > sizeof(To)) || // NOLINT(misc-redundant-expression)
18681868
(std::is_enum_v<From> && std::is_integral_v<To> && sizeof(From) > sizeof(To)) ||
18691869
// [dcl.init.list] 7.5
18701870
(std::is_pointer_v<From> && std::is_same_v<To, bool>)

source/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,8 @@ class cmdline_processor
880880
-> void
881881
{
882882
help_requested = true;
883-
std::string_view a = __DATE__;
884-
std::string_view b = __TIME__;
883+
const std::string_view a = __DATE__;
884+
const std::string_view b = __TIME__;
885885
std::unordered_map<std::string_view, char> m = { {"Jan",'1'}, {"Feb",'2'}, {"Mar",'3'}, {"Apr",'4'}, {"May",'5'}, {"Jun",'6'}, {"Jul",'7'}, {"Aug",'8'}, {"Sep",'9'}, {"Oct",'A'}, {"Nov",'B'}, {"Dec",'C'} };
886886

887887
auto stamp = std::to_string(atoi(&a[9])-15);

source/parse.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6105,7 +6105,7 @@ class parser
61056105
// Remember current position, because we may need to backtrack
61066106
auto start_pos = pos;
61076107

6108-
bool inside_initializer = (
6108+
const bool inside_initializer = (
61096109
peek(-1) && peek(-1)->type() == lexeme::Assignment
61106110
);
61116111
auto open_paren = &curr();
@@ -8069,7 +8069,7 @@ class parser
80698069
)
80708070
-> std::unique_ptr<compound_statement_node>
80718071
{
8072-
bool is_braced = curr().type() == lexeme::LeftBrace;
8072+
const bool is_braced = curr().type() == lexeme::LeftBrace;
80738073
if (
80748074
!is_braced
80758075
&& !allow_single_unbraced_statement

source/sema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ class sema
12951295
assert (std::ssize(selection_stack.back().branches) > 0);
12961296
selection_stack.back().branches.back().result = sym.standalone_assignment_to;
12971297

1298-
int this_depth = symbols[pos].depth;
1298+
const int this_depth = symbols[pos].depth;
12991299
while (symbols[pos + 1].depth >= this_depth) {
13001300
++pos;
13011301
}
@@ -1320,7 +1320,7 @@ class sema
13201320

13211321
// The depth of this branch should always be the depth of
13221322
// the current selection statement + 1
1323-
int branch_depth = symbols[selection_stack.back().pos].depth + 1;
1323+
const int branch_depth = symbols[selection_stack.back().pos].depth + 1;
13241324
while (symbols[pos + 1].depth > branch_depth) {
13251325
++pos;
13261326
}

source/to_cpp1.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ class cppfront
17391739

17401740
// We always want to std::move from named return values,
17411741
// regardless of their types, so use std::move for that
1742-
bool add_std_move =
1742+
const bool add_std_move =
17431743
synthesized_multi_return_size > 1
17441744
|| (
17451745
synthesized_multi_return_size == 1
@@ -1763,7 +1763,7 @@ class cppfront
17631763

17641764
// Add `cpp2::move(*this).` when implicitly moving a member on last use
17651765
// This way, members of lvalue reference type won't be implicitly moved
1766-
bool add_this =
1766+
const bool add_this =
17671767
add_move
17681768
&& decl
17691769
&& decl->identifier

0 commit comments

Comments
 (0)