Get ready for clang-tidy 22
diff --git a/.clang-tidy b/.clang-tidy index 4bb9cbb..70ee773 100644 --- a/.clang-tidy +++ b/.clang-tidy
@@ -54,6 +54,8 @@ -readability-named-parameter, -readability-qualified-auto, -readability-redundant-access-specifiers, + -readability-redundant-parentheses, + -readability-redundant-typename, -readability-simplify-boolean-expr, -readability-static-definition-in-anonymous-namespace, -readability-uppercase-literal-suffix, @@ -104,4 +106,3 @@ value: .*-linter-test-utils\.h - key: misc-override-with-different-visibility.DisallowedVisibilityChange value: widening -
diff --git a/verible/common/analysis/lint-waiver_test.cc b/verible/common/analysis/lint-waiver_test.cc index 8087230..efe4bbd 100644 --- a/verible/common/analysis/lint-waiver_test.cc +++ b/verible/common/analysis/lint-waiver_test.cc
@@ -141,6 +141,7 @@ constexpr char kWaiveStopCommand[] = "waive-end"; // Helper class for testing an example of a waiver. +// NOLINTNEXTLINE(misc-multiple-inheritance) class LintWaiverBuilderTest : public testing::Test, public LintWaiverBuilder { public: LintWaiverBuilderTest()
diff --git a/verible/common/formatting/align.cc b/verible/common/formatting/align.cc index e72b5f6..9986fc7 100644 --- a/verible/common/formatting/align.cc +++ b/verible/common/formatting/align.cc
@@ -258,7 +258,7 @@ if (padding_len > 0) { if (lines[level].empty()) { lines[level].append(std::string(padding_len, ' ')); - } else if (padding_len > int(kCellSeparator.size())) { + } else if (padding_len > static_cast<int>(kCellSeparator.size())) { lines[level].append(absl::StrCat( kCellSeparator, std::string(padding_len - kCellSeparator.size(), ' ')));
diff --git a/verible/common/formatting/align_test.cc b/verible/common/formatting/align_test.cc index 5b9a96f..d667697 100644 --- a/verible/common/formatting/align_test.cc +++ b/verible/common/formatting/align_test.cc
@@ -65,6 +65,7 @@ // Helper class that initializes an array of tokens to be partitioned // into TokenPartitionTree. +// NOLINTNEXTLINE(misc-multiple-inheritance) class AlignmentTestFixture : public ::testing::Test, public UnwrappedLineMemoryHandler { public: @@ -1284,6 +1285,7 @@ "( eleven nineteen-ninety-nine 2k )\n") : SubcolumnsTreeAlignmentTest(text) {} + // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method) std::string Render() { std::ostringstream stream; int position = 0; @@ -1490,6 +1492,7 @@ const char stop_; }; +// NOLINTNEXTLINE(misc-multiple-inheritance) class FormatUsingOriginalSpacingTest : public ::testing::Test, public UnwrappedLineMemoryHandler { public:
diff --git a/verible/common/formatting/format-token_test.cc b/verible/common/formatting/format-token_test.cc index d261cf9..a56bd16 100644 --- a/verible/common/formatting/format-token_test.cc +++ b/verible/common/formatting/format-token_test.cc
@@ -213,6 +213,7 @@ } } +// NOLINTNEXTLINE(misc-multiple-inheritance) class ConnectPreFormatTokensPreservedSpaceStartsTest : public ::testing::Test, public UnwrappedLineMemoryHandler {}; @@ -260,6 +261,7 @@ text.substr(5, 3))); // "\t\t\n" } +// NOLINTNEXTLINE(misc-multiple-inheritance) class PreserveSpacesOnDisabledTokenRangesTest : public ::testing::Test, public UnwrappedLineMemoryHandler {};
diff --git a/verible/common/formatting/layout-optimizer.cc b/verible/common/formatting/layout-optimizer.cc index 03eace9..38f1b4a 100644 --- a/verible/common/formatting/layout-optimizer.cc +++ b/verible/common/formatting/layout-optimizer.cc
@@ -125,7 +125,7 @@ case LayoutType::kStack: return stream << "stack"; } - LOG(WARNING) << "Unknown layout type: " << int(type); + LOG(WARNING) << "Unknown layout type: " << static_cast<int>(type); return stream << "???"; } @@ -227,7 +227,8 @@ } return LayoutFunction{ {0, std::move(layout), span, - float((span - style_.column_limit) * style_.over_column_limit_penalty), + static_cast<float>((span - style_.column_limit) * + style_.over_column_limit_penalty), style_.over_column_limit_penalty}, }; }
diff --git a/verible/common/formatting/layout-optimizer_test.cc b/verible/common/formatting/layout-optimizer_test.cc index ab8b91b..f9d13e7 100644 --- a/verible/common/formatting/layout-optimizer_test.cc +++ b/verible/common/formatting/layout-optimizer_test.cc
@@ -149,6 +149,7 @@ return left.TokensRange() == right.TokensRange(); } +// NOLINTNEXTLINE(misc-multiple-inheritance) class LayoutTest : public ::testing::Test, public UnwrappedLineMemoryHandler { public: LayoutTest() @@ -659,6 +660,7 @@ } } +// NOLINTNEXTLINE(misc-multiple-inheritance) class LayoutFunctionFactoryTest : public ::testing::Test, public UnwrappedLineMemoryHandler { public: @@ -1967,6 +1969,7 @@ } } +// NOLINTNEXTLINE(misc-multiple-inheritance) class TreeReconstructorTest : public ::testing::Test, public UnwrappedLineMemoryHandler { public: @@ -2321,6 +2324,7 @@ tree_expected); } +// NOLINTNEXTLINE(misc-multiple-inheritance) class OptimizeTokenPartitionTreeTest : public ::testing::Test, public UnwrappedLineMemoryHandler { public: @@ -2383,6 +2387,7 @@ EXPECT_PRED_FORMAT2(TokenPartitionTreesEqualPredFormat, tree, expected_tree); } +// NOLINTNEXTLINE(misc-multiple-inheritance) class TokenPartitionsLayoutOptimizerTest : public ::testing::Test, public UnwrappedLineMemoryHandler { public:
diff --git a/verible/common/formatting/line-wrap-searcher_test.cc b/verible/common/formatting/line-wrap-searcher_test.cc index 5ae39e6..612891e 100644 --- a/verible/common/formatting/line-wrap-searcher_test.cc +++ b/verible/common/formatting/line-wrap-searcher_test.cc
@@ -30,6 +30,7 @@ namespace { // This test class just binds a set of style parameters. +// NOLINTNEXTLINE(misc-multiple-inheritance) class SearchLineWrapsTestFixture : public UnwrappedLineMemoryHandler, public ::testing::Test { public:
diff --git a/verible/common/formatting/state-node_test.cc b/verible/common/formatting/state-node_test.cc index c939b7e..c019ae9 100644 --- a/verible/common/formatting/state-node_test.cc +++ b/verible/common/formatting/state-node_test.cc
@@ -42,6 +42,7 @@ return formatted_line.Render(); } +// NOLINTNEXTLINE(misc-multiple-inheritance) struct StateNodeTestFixture : public UnwrappedLineMemoryHandler, public ::testing::Test { StateNodeTestFixture() {
diff --git a/verible/common/formatting/token-partition-tree_test.cc b/verible/common/formatting/token-partition-tree_test.cc index 19b6a16..3e2acca 100644 --- a/verible/common/formatting/token-partition-tree_test.cc +++ b/verible/common/formatting/token-partition-tree_test.cc
@@ -41,6 +41,7 @@ // Helper class that initializes an array of tokens to be partitioned // into TokenPartitionTree. +// NOLINTNEXTLINE(misc-multiple-inheritance) class TokenPartitionTreeTestFixture : public ::testing::Test, public UnwrappedLineMemoryHandler { public: @@ -1231,6 +1232,7 @@ } } +// NOLINTNEXTLINE(misc-multiple-inheritance) class GetSubpartitionsBetweenBlankLinesTest : public ::testing::Test, public UnwrappedLineMemoryHandler { @@ -2691,6 +2693,7 @@ } // Tests with real-world example +// NOLINTNEXTLINE(misc-multiple-inheritance) class ReshapeFittingSubpartitionsTestFixture : public ::testing::Test, public UnwrappedLineMemoryHandler {
diff --git a/verible/common/formatting/tree-unwrapper_test.cc b/verible/common/formatting/tree-unwrapper_test.cc index d7ed6a6..2400bbc 100644 --- a/verible/common/formatting/tree-unwrapper_test.cc +++ b/verible/common/formatting/tree-unwrapper_test.cc
@@ -60,6 +60,7 @@ std::vector<verible::PreFormatToken> preformatted_tokens_; }; +// NOLINTNEXTLINE(misc-multiple-inheritance) class FakeTreeUnwrapper : public TreeUnwrapperData, public TreeUnwrapper { public: explicit FakeTreeUnwrapper(const TextStructureView &view)
diff --git a/verible/common/formatting/unwrapped-line.cc b/verible/common/formatting/unwrapped-line.cc index e60daad..d4229c1 100644 --- a/verible/common/formatting/unwrapped-line.cc +++ b/verible/common/formatting/unwrapped-line.cc
@@ -61,7 +61,7 @@ case PartitionPolicyEnum::kJuxtapositionOrIndentedStack: return stream << "juxtaposition-or-indented-stack"; } - LOG(FATAL) << "Unknown partition policy " << int(p); + LOG(FATAL) << "Unknown partition policy " << static_cast<int>(p); } static void TokenFormatter(std::string *out, const PreFormatToken &token,
diff --git a/verible/common/formatting/unwrapped-line_test.cc b/verible/common/formatting/unwrapped-line_test.cc index 9f3eb3a..f9b6dbb 100644 --- a/verible/common/formatting/unwrapped-line_test.cc +++ b/verible/common/formatting/unwrapped-line_test.cc
@@ -90,6 +90,7 @@ // This test fixture inherits from UnwrappedLineMemoryHandler so that // UnwrappedLine's internal references can safely point to backed storage. +// NOLINTNEXTLINE(misc-multiple-inheritance) class UnwrappedLineTest : public UnwrappedLineMemoryHandler, public testing::Test { protected:
diff --git a/verible/common/lsp/json-rpc-dispatcher.cc b/verible/common/lsp/json-rpc-dispatcher.cc index d1a9e66..2703b29 100644 --- a/verible/common/lsp/json-rpc-dispatcher.cc +++ b/verible/common/lsp/json-rpc-dispatcher.cc
@@ -35,7 +35,7 @@ return; } - if (request.find("method") == request.end()) { + if (!request.contains("method")) { SendReply( CreateError(request, kMethodNotFound, "Method required in request")); ++statistic_counters_["Request without method"]; @@ -44,7 +44,7 @@ const std::string &method = request["method"]; // Direct dispatch, later maybe send to an executor that returns futures ? - const bool is_notification = (request.find("id") == request.end()); + const bool is_notification = !request.contains("id"); VLOG(1) << "Got " << (is_notification ? "notification" : "method call") << " '" << method << "'; req-size: " << data.size(); bool handled = false; @@ -124,8 +124,8 @@ result["error"]["message"] = message; } - if (request.find("id") != request.end()) { - result["id"] = request["id"]; + if (auto found = request.find("id"); found != request.end()) { + result["id"] = found.value(); } return result;
diff --git a/verible/common/lsp/json-rpc-dispatcher_test.cc b/verible/common/lsp/json-rpc-dispatcher_test.cc index 01d2ee7..f8139b0 100644 --- a/verible/common/lsp/json-rpc-dispatcher_test.cc +++ b/verible/common/lsp/json-rpc-dispatcher_test.cc
@@ -32,7 +32,7 @@ // If the input can't even be parsed, it is reported back to the client JsonRpcDispatcher dispatcher([&](std::string_view s) { const json j = json::parse(s); - EXPECT_TRUE(j.find("error") != j.end()); + EXPECT_TRUE(j.contains("error")); EXPECT_EQ(j["error"]["code"], JsonRpcDispatcher::kParseError) << s; ++write_fun_called; }); @@ -50,7 +50,7 @@ JsonRpcDispatcher dispatcher([&](std::string_view s) { const json j = json::parse(s); - EXPECT_TRUE(j.find("error") != j.end()); + EXPECT_TRUE(j.contains("error")); EXPECT_EQ(j["error"]["code"], JsonRpcDispatcher::kMethodNotFound) << s; ++write_fun_called; }); @@ -152,7 +152,7 @@ JsonRpcDispatcher dispatcher([&](std::string_view s) { const json j = json::parse(s); EXPECT_EQ(std::string(j["result"]["some"]), "response"); - EXPECT_TRUE(j.find("error") == j.end()); + EXPECT_FALSE(j.contains("error")); ++write_fun_called; }); const bool registered = @@ -182,7 +182,7 @@ JsonRpcDispatcher dispatcher([&](std::string_view s) { const json j = json::parse(s); EXPECT_EQ(std::string(j["result"]["some"]), "response"); - EXPECT_TRUE(j.find("error") == j.end()); + EXPECT_FALSE(j.contains("error")); ++write_fun_called; }); const bool registered = @@ -207,7 +207,7 @@ JsonRpcDispatcher dispatcher([&](std::string_view s) { const json j = json::parse(s); - EXPECT_TRUE(j.find("error") != j.end()); + EXPECT_TRUE(j.contains("error")); EXPECT_EQ(j["error"]["code"], JsonRpcDispatcher::kInternalError) << s; ++write_fun_called; }); @@ -231,7 +231,7 @@ JsonRpcDispatcher dispatcher([&](std::string_view s) { const json j = json::parse(s); - EXPECT_TRUE(j.find("error") != j.end()); + EXPECT_TRUE(j.contains("error")); EXPECT_EQ(j["error"]["code"], JsonRpcDispatcher::kMethodNotFound) << s; ++write_fun_called; });
diff --git a/verible/common/lsp/message-stream-splitter_test.cc b/verible/common/lsp/message-stream-splitter_test.cc index d70f101..2de2d6c 100644 --- a/verible/common/lsp/message-stream-splitter_test.cc +++ b/verible/common/lsp/message-stream-splitter_test.cc
@@ -46,7 +46,7 @@ int read(char *buf, int size) { if (max_chunk_ > 0 && size > max_chunk_) size = max_chunk_; - size = std::min(size, (int)content_.length() - read_pos_); + size = std::min(size, static_cast<int>(content_.length() - read_pos_)); memcpy(buf, content_.data() + read_pos_, size); read_pos_ += size; return size;
diff --git a/verible/common/strings/diff.cc b/verible/common/strings/diff.cc index 3f274d8..6cb9375 100644 --- a/verible/common/strings/diff.cc +++ b/verible/common/strings/diff.cc
@@ -207,10 +207,10 @@ // Last line from either original or new text, and final '\n' is missing? if ((edit.operation != Operation::INSERT && - size_t(edit.end) == linediffs.before_lines.size() && + static_cast<size_t>(edit.end) == linediffs.before_lines.size() && linediffs.before_text.back() != '\n') || (edit.operation == Operation::INSERT && - size_t(edit.end) == linediffs.after_lines.size() && + static_cast<size_t>(edit.end) == linediffs.after_lines.size() && linediffs.after_text.back() != '\n')) { stream << "\\ No newline at end of file" << std::endl; }
diff --git a/verible/common/strings/obfuscator.h b/verible/common/strings/obfuscator.h index 782fd86..0d529fe 100644 --- a/verible/common/strings/obfuscator.h +++ b/verible/common/strings/obfuscator.h
@@ -93,6 +93,7 @@ explicit IdentifierObfuscator(const generator_type &g) : Obfuscator(g) {} // Same as inherited method, but verifies that key and value are equal length. + // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method) bool encode(std::string_view key, std::string_view value); };
diff --git a/verible/common/strings/patch_test.cc b/verible/common/strings/patch_test.cc index 42e7c51..17a4930 100644 --- a/verible/common/strings/patch_test.cc +++ b/verible/common/strings/patch_test.cc
@@ -1030,6 +1030,7 @@ } } +// NOLINTNEXTLINE(misc-multiple-inheritance) class FilePatchPickApplyTest : public FilePatch, public ::testing::Test { protected: absl::Status ParseLines(const std::vector<std::string_view> &lines) { @@ -2200,6 +2201,7 @@ // Neither case should include deleted files like file3.txt } +// NOLINTNEXTLINE(misc-multiple-inheritance) class PatchSetPickApplyTest : public PatchSet, public ::testing::Test {}; TEST_F(PatchSetPickApplyTest, EmptyFilePatchHunks) {
diff --git a/verible/common/text/macro-definition.h b/verible/common/text/macro-definition.h index 8f86a1f..f78501c 100644 --- a/verible/common/text/macro-definition.h +++ b/verible/common/text/macro-definition.h
@@ -38,6 +38,7 @@ explicit DefaultTokenInfo(const TokenInfo &t) : TokenInfo(t) {} // Accept a plain TokenInfo for assignment purposes. + // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method) DefaultTokenInfo &operator=(const TokenInfo &t) { TokenInfo::operator=(t); return *this;
diff --git a/verible/common/text/syntax-tree-context.h b/verible/common/text/syntax-tree-context.h index 473e445..451835c 100644 --- a/verible/common/text/syntax-tree-context.h +++ b/verible/common/text/syntax-tree-context.h
@@ -48,6 +48,7 @@ public: // returns the top SyntaxTreeNode of the stack + // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method) const SyntaxTreeNode &top() const { return *ABSL_DIE_IF_NULL(base_type::top()); }
diff --git a/verible/common/text/text-structure_test.cc b/verible/common/text/text-structure_test.cc index 8f90a56..e862f29 100644 --- a/verible/common/text/text-structure_test.cc +++ b/verible/common/text/text-structure_test.cc
@@ -175,6 +175,7 @@ } // Helper class for testing Token range methods. +// NOLINTNEXTLINE(misc-multiple-inheritance) class TokenRangeTest : public ::testing::Test, public TextStructureTokenized { public: static constexpr int kSpace = 2; @@ -335,6 +336,7 @@ } // Testing select public methods of TextStructureView. +// NOLINTNEXTLINE(misc-multiple-inheritance) class TextStructureViewPublicTest : public ::testing::Test, public TextStructureView { public:
diff --git a/verible/common/text/token-stream-view_test.cc b/verible/common/text/token-stream-view_test.cc index 071de8c..bbabe17 100644 --- a/verible/common/text/token-stream-view_test.cc +++ b/verible/common/text/token-stream-view_test.cc
@@ -69,6 +69,7 @@ } // Helper class for testing Token range methods. +// NOLINTNEXTLINE(misc-multiple-inheritance) class TokenViewRangeTest : public ::testing::Test, public TextStructureTokenized { public:
diff --git a/verible/common/text/tree-context-visitor.cc b/verible/common/text/tree-context-visitor.cc index 955f4dd..3d1aac4 100644 --- a/verible/common/text/tree-context-visitor.cc +++ b/verible/common/text/tree-context-visitor.cc
@@ -66,15 +66,16 @@ static int CompareSyntaxTreePath(const SyntaxTreePath &a, const SyntaxTreePath &b, int index) { // a[index] ? b[index] - if (int(a.size()) > index && int(b.size()) > index) { + if (static_cast<int>(a.size()) > index && + static_cast<int>(b.size()) > index) { if (a[index] < b[index]) return -1; if (a[index] > b[index]) return 1; if (a[index] == b[index]) return CompareSyntaxTreePath(a, b, index + 1); } // a[index] ? (out-of-bounds) - if (int(a.size()) > index) return (a[index] < 0) ? -1 : 1; + if (static_cast<int>(a.size()) > index) return (a[index] < 0) ? -1 : 1; // (out-of-bounds) ? b[index] - if (int(b.size()) > index) return (0 > b[index]) ? 1 : -1; + if (static_cast<int>(b.size()) > index) return (0 > b[index]) ? 1 : -1; // (out-of-bounds) == (out-of-bounds) return 0; }
diff --git a/verible/common/util/enum-flags_test.cc b/verible/common/util/enum-flags_test.cc index c66b204..c70036c 100644 --- a/verible/common/util/enum-flags_test.cc +++ b/verible/common/util/enum-flags_test.cc
@@ -45,6 +45,7 @@ }) {} }; +// NOLINTNEXTLINE(misc-multiple-inheritance) class EnumNameMapTest : public ::testing::Test, public TestMapType { public: EnumNameMapTest() = default;
diff --git a/verible/common/util/sha256.cc b/verible/common/util/sha256.cc index 2c4a5bb..cfcf692 100644 --- a/verible/common/util/sha256.cc +++ b/verible/common/util/sha256.cc
@@ -43,6 +43,7 @@ #include "absl/strings/escaping.h" +// NOLINTBEGIN(modernize-avoid-c-style-cast) namespace verible { namespace { @@ -268,5 +269,5 @@ return absl::BytesToHexString(std::string_view( reinterpret_cast<const char *>(sha256bytes.data()), sha256bytes.size())); } - +// NOLINTEND(modernize-avoid-c-style-cast) } // namespace verible
diff --git a/verible/common/util/tree-operations.h b/verible/common/util/tree-operations.h index 8e10038..b70da51 100644 --- a/verible/common/util/tree-operations.h +++ b/verible/common/util/tree-operations.h
@@ -164,7 +164,7 @@ // No-op candidate used when Container doesn't provide `reserve()` method. template <class Container> -void ReserveIfSupported(Container &, ...) {} +void ReserveIfSupported(Container &, ...) {} // NOLINT } // namespace tree_operations_internal
diff --git a/verible/verilog/CST/declaration.h b/verible/verilog/CST/declaration.h index cd325cf..7276b21 100644 --- a/verible/verilog/CST/declaration.h +++ b/verible/verilog/CST/declaration.h
@@ -78,7 +78,7 @@ verible::SymbolPtr MakeDataDeclaration(T1 &&qualifiers, T2 &&inst_base, T3 &&semicolon) { verible::CheckOptionalSymbolAsNode(qualifiers, NodeEnum::kQualifierList); - if (inst_base.get()->Tag().tag == (int)NodeEnum::kFunctionCall) { + if (inst_base.get()->Tag().tag == static_cast<int>(NodeEnum::kFunctionCall)) { return verible::ExtendNode(std::forward<T2>(inst_base), std::forward<T3>(semicolon)); }
diff --git a/verible/verilog/CST/expression.cc b/verible/verilog/CST/expression.cc index 7256626..b8f8b84 100644 --- a/verible/verilog/CST/expression.cc +++ b/verible/verilog/CST/expression.cc
@@ -170,7 +170,9 @@ const verible::Symbol &reference) { // remove calls since they are not simple - but a ReferenceCallBase can be // just a reference, depending on where it is placed in the code - if (reference.Tag().tag == (int)NodeEnum::kReferenceCallBase) return nullptr; + if (reference.Tag().tag == static_cast<int>(NodeEnum::kReferenceCallBase)) { + return nullptr; + } const auto &reference_node( verible::CheckSymbolAsNode(reference, NodeEnum::kReference)); // A simple reference contains one component without hierarchy, indexing, or
diff --git a/verible/verilog/CST/functions.cc b/verible/verilog/CST/functions.cc index 357e790..64f4e91 100644 --- a/verible/verilog/CST/functions.cc +++ b/verible/verilog/CST/functions.cc
@@ -141,21 +141,22 @@ const verible::Symbol *identifier = nullptr; reference_call_base = GetSubtreeAsSymbol(function_call, NodeEnum::kFunctionCall, 0); - if (reference_call_base->Tag().tag != (int)NodeEnum::kReferenceCallBase) { + if (reference_call_base->Tag().tag != + static_cast<int>(NodeEnum::kReferenceCallBase)) { return nullptr; } reference = GetSubtreeAsSymbol(*reference_call_base, NodeEnum::kReferenceCallBase, 0); if (!reference) return nullptr; - if (reference->Tag().tag == (int)NodeEnum::kReference) { + if (reference->Tag().tag == static_cast<int>(NodeEnum::kReference)) { const verible::SyntaxTreeNode *local_root = GetSubtreeAsNode( *reference, NodeEnum::kReference, 0, NodeEnum::kLocalRoot); if (!local_root) return nullptr; - if (local_root->Tag().tag != (int)NodeEnum::kLocalRoot) { + if (local_root->Tag().tag != static_cast<int>(NodeEnum::kLocalRoot)) { return nullptr; } identifier = GetIdentifiersFromLocalRoot(*local_root); - } else if (reference->Tag().tag == (int)NodeEnum::kMacroCall) { + } else if (reference->Tag().tag == static_cast<int>(NodeEnum::kMacroCall)) { return &verible::SymbolCastToNode(*reference); } if (!identifier) return nullptr; @@ -191,10 +192,11 @@ const verible::SyntaxTreeNode *GetParenGroupFromCall( const verible::Symbol &function_call) { - if (function_call.Tag().tag == (int)NodeEnum::kFunctionCall) { + if (function_call.Tag().tag == static_cast<int>(NodeEnum::kFunctionCall)) { const verible::Symbol *reference_or_call = verible::GetSubtreeAsSymbol(function_call, NodeEnum::kFunctionCall, 0); - if (reference_or_call->Tag().tag != (int)NodeEnum::kReferenceCallBase) { + if (reference_or_call->Tag().tag != + static_cast<int>(NodeEnum::kReferenceCallBase)) { return nullptr; } return verible::GetSubtreeAsNode(*reference_or_call,
diff --git a/verible/verilog/CST/port_test.cc b/verible/verilog/CST/port_test.cc index 7662a0c..5eb1331 100644 --- a/verible/verilog/CST/port_test.cc +++ b/verible/verilog/CST/port_test.cc
@@ -541,10 +541,9 @@ std::vector<TreeSearchMatch> directions; for (const auto &port : ports) { - const auto *direction = + const verible::SyntaxTreeLeaf *direction = GetDirectionFromPortDeclaration(*port.match); - directions.emplace_back( - TreeSearchMatch{(const verible::Symbol *)direction, {}}); + directions.emplace_back(TreeSearchMatch{direction, {}}); } return directions; });
diff --git a/verible/verilog/CST/type.cc b/verible/verilog/CST/type.cc index 89c526f..aa1efdf 100644 --- a/verible/verilog/CST/type.cc +++ b/verible/verilog/CST/type.cc
@@ -171,8 +171,9 @@ const auto *local_root = verible::GetSubtreeAsNode(data_type, NodeEnum::kDataType, 1); if (!local_root) return nullptr; - if (local_root->Tag().tag != (int)NodeEnum::kLocalRoot) return local_root; - + if (local_root->Tag().tag != static_cast<int>(NodeEnum::kLocalRoot)) { + return local_root; + } CHECK(!local_root->empty()); const auto &children = local_root->children(); verible::Symbol *last_child = nullptr;
diff --git a/verible/verilog/analysis/verilog-analyzer_test.cc b/verible/verilog/analysis/verilog-analyzer_test.cc index b3b2e57..96cc449 100644 --- a/verible/verilog/analysis/verilog-analyzer_test.cc +++ b/verible/verilog/analysis/verilog-analyzer_test.cc
@@ -850,6 +850,7 @@ } // Helper class for testing internals. +// NOLINTNEXTLINE(misc-multiple-inheritance) class VerilogAnalyzerInternalsTest : public testing::Test, public VerilogAnalyzer { public:
diff --git a/verible/verilog/parser/verilog-lexical-context.cc b/verible/verilog/parser/verilog-lexical-context.cc index 7eaa019..740e3fe 100644 --- a/verible/verilog/parser/verilog-lexical-context.cc +++ b/verible/verilog/parser/verilog-lexical-context.cc
@@ -80,7 +80,7 @@ std::ostream &ConstraintBlockStateMachine::Dump(std::ostream &os) const { os << '[' << states_.size() << ']'; if (!states_.empty()) { - os << ": top:" << int(states_.top()); + os << ": top:" << static_cast<int>(states_.top()); } return os; }
diff --git a/verible/verilog/parser/verilog-lexical-context_test.cc b/verible/verilog/parser/verilog-lexical-context_test.cc index 733186b..b800e65 100644 --- a/verible/verilog/parser/verilog-lexical-context_test.cc +++ b/verible/verilog/parser/verilog-lexical-context_test.cc
@@ -184,6 +184,7 @@ } } +// NOLINTNEXTLINE(misc-multiple-inheritance) class LastSemicolonStateMachineTest : public ::testing::Test, public internal::LastSemicolonStateMachine { @@ -1150,6 +1151,7 @@ } // Class for testing some internal methods of LexicalContext. +// NOLINTNEXTLINE(misc-multiple-inheritance) class LexicalContextTest : public ::testing::Test, public LexicalContext { protected: LexicalContextTest() = default;
diff --git a/verible/verilog/tools/kythe/indexing-facts-tree-context.h b/verible/verilog/tools/kythe/indexing-facts-tree-context.h index 6173a15..8016c3d 100644 --- a/verible/verilog/tools/kythe/indexing-facts-tree-context.h +++ b/verible/verilog/tools/kythe/indexing-facts-tree-context.h
@@ -34,6 +34,7 @@ public: // returns the top IndexingFactsNode of the stack. + // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method) IndexingFactNode &top() { return *ABSL_DIE_IF_NULL(base_type::top()); } };
diff --git a/verible/verilog/tools/kythe/kythe-facts-extractor.cc b/verible/verilog/tools/kythe/kythe-facts-extractor.cc index 65b6745..b49b8c1 100644 --- a/verible/verilog/tools/kythe/kythe-facts-extractor.cc +++ b/verible/verilog/tools/kythe/kythe-facts-extractor.cc
@@ -88,6 +88,7 @@ using AutoPop = base_type::AutoPop; // returns the top VName of the stack + // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method) const VName &top() const { return *ABSL_DIE_IF_NULL(base_type::top()); } };