From e4487505ddc34d7e259f3b1bc27cb9b687054418 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Mon, 27 Feb 2023 08:23:11 -0800 Subject: [PATCH] Update clang-tidy details for the toolchain (#2623) Adjusts handling of class constants (`static const`) to use CamelCase. This probably better reflects how we use it in C++ code, treating as appropriate for CamelCase instead of under_score. Fixes adding_children to be preorder in caller (not sure why this wasn't automated). No automated changes. --- .clang-tidy | 1 + toolchain/parser/parse_tree.cpp | 4 ++-- toolchain/parser/parse_tree.h | 1 - toolchain/semantics/semantics_builtin_kind.h | 3 +-- toolchain/semantics/semantics_node.h | 3 --- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3da7d6bf2dd2..6429e4b7854d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -25,6 +25,7 @@ Checks: WarningsAsErrors: true CheckOptions: - { key: readability-identifier-naming.ClassCase, value: CamelCase } + - { key: readability-identifier-naming.ClassConstantCase, value: CamelCase } - { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase, diff --git a/toolchain/parser/parse_tree.cpp b/toolchain/parser/parse_tree.cpp index 4a2a8e4f595b..6b642fb5764e 100644 --- a/toolchain/parser/parse_tree.cpp +++ b/toolchain/parser/parse_tree.cpp @@ -135,7 +135,7 @@ auto ParseTree::Print(llvm::raw_ostream& output) const -> void { output << "[\n"; for (Node n : postorder()) { - PrintNode(output, n, indents[n.index], /*adding_children=*/false); + PrintNode(output, n, indents[n.index], /*preorder=*/false); output << ",\n"; } output << "]\n"; @@ -165,7 +165,7 @@ auto ParseTree::Print(llvm::raw_ostream& output, bool preorder) const -> void { int depth; std::tie(n, depth) = node_stack.pop_back_val(); - if (PrintNode(output, n, depth, /*adding_children=*/true)) { + if (PrintNode(output, n, depth, /*preorder=*/true)) { // Has children, so we descend. We append the children in order here as // well because they will get reversed when popped off the stack. for (Node sibling_n : children(n)) { diff --git a/toolchain/parser/parse_tree.h b/toolchain/parser/parse_tree.h index 34eb7ac7dc21..7ec2f43fa099 100644 --- a/toolchain/parser/parse_tree.h +++ b/toolchain/parser/parse_tree.h @@ -243,7 +243,6 @@ class ParseTree { // sequence across all nodes in the parse tree. struct ParseTree::Node : public ComparableIndexBase { // An explicitly invalid instance. - // NOLINTNEXTLINE(readability-identifier-naming) static const Node Invalid; using ComparableIndexBase::ComparableIndexBase; diff --git a/toolchain/semantics/semantics_builtin_kind.h b/toolchain/semantics/semantics_builtin_kind.h index 53a9d919c64b..408d9e56ac89 100644 --- a/toolchain/semantics/semantics_builtin_kind.h +++ b/toolchain/semantics/semantics_builtin_kind.h @@ -26,8 +26,7 @@ class SemanticsBuiltinKind : public CARBON_ENUM_BASE(SemanticsBuiltinKind) { // The count of enum values excluding Invalid. // // Note that we *define* this as `constexpr` making it a true compile-time - // constant, and so we name it accordingly and disable the lint error here. - // NOLINTNEXTLINE(readability-identifier-naming) + // constant. static const uint8_t ValidCount; // Support conversion to and from an int32_t for SemanticNode storage. diff --git a/toolchain/semantics/semantics_node.h b/toolchain/semantics/semantics_node.h index b452da766130..252f5333253f 100644 --- a/toolchain/semantics/semantics_node.h +++ b/toolchain/semantics/semantics_node.h @@ -18,7 +18,6 @@ namespace Carbon { // The ID of a node. struct SemanticsNodeId : public IndexBase { // An explicitly invalid node ID. - // NOLINTNEXTLINE(readability-identifier-naming) static const SemanticsNodeId Invalid; // Builtin node IDs. @@ -82,11 +81,9 @@ struct SemanticsIntegerLiteralId : public IndexBase { // The ID of a node block. struct SemanticsNodeBlockId : public IndexBase { // All SemanticsIR instances must provide the 0th node block as empty. - // NOLINTNEXTLINE(readability-identifier-naming) static const SemanticsNodeBlockId Empty; // An explicitly invalid ID. - // NOLINTNEXTLINE(readability-identifier-naming) static const SemanticsNodeBlockId Invalid; using IndexBase::IndexBase;