Просмотр исходного кода

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.
Jon Ross-Perkins 3 лет назад
Родитель
Сommit
e4487505dd

+ 1 - 0
.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,

+ 2 - 2
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)) {

+ 0 - 1
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;

+ 1 - 2
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.

+ 0 - 3
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;