From a2bc2e38f9b7142271119f7f8dca1f220f931d28 Mon Sep 17 00:00:00 2001 From: cyy Date: Tue, 5 Nov 2024 16:00:25 +0000 Subject: [PATCH] Use clang-tidy 17 (#139678) Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/139678 Approved by: https://github.com/Skylion007 --- .clang-tidy | 2 +- c10/core/Allocator.h | 2 +- c10/test/util/Metaprogramming_test.cpp | 1 + c10/test/util/logging_test.cpp | 1 + c10/util/Bitset.h | 1 + c10/util/signal_handler.cpp | 1 + tools/linter/adapters/s3_init_config.json | 4 ++-- torch/csrc/autograd/python_nn_functions.h | 2 +- 8 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index deff8f0fb8d..3b03412a405 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -64,5 +64,5 @@ readability-string-compare, HeaderFilterRegex: '^(aten/|c10/|torch/).*$' WarningsAsErrors: '*' CheckOptions: - misc-header-include-cycle.IgnoredFilesList: 'format.h;ivalue.h;custom_class.h;Dict.h;List.h' + misc-header-include-cycle.IgnoredFilesList: 'format.h;ivalue.h;custom_class.h;Dict.h;List.h;IListRef.h' ... diff --git a/c10/core/Allocator.h b/c10/core/Allocator.h index bdb8c719fbc..c881d104934 100644 --- a/c10/core/Allocator.h +++ b/c10/core/Allocator.h @@ -234,7 +234,7 @@ struct C10_API InefficientStdFunctionContext { deleter_(std::move(rhs.deleter_)) {} InefficientStdFunctionContext& operator=( const InefficientStdFunctionContext&) = delete; - // NOLINTNEXTLINE(performance-noexcept-move-constructor) + // NOLINTNEXTLINE(*-noexcept-move-*) InefficientStdFunctionContext& operator=( InefficientStdFunctionContext&& rhs) { this->~InefficientStdFunctionContext(); diff --git a/c10/test/util/Metaprogramming_test.cpp b/c10/test/util/Metaprogramming_test.cpp index 1a1819d9d5c..ad301462bd5 100644 --- a/c10/test/util/Metaprogramming_test.cpp +++ b/c10/test/util/Metaprogramming_test.cpp @@ -230,6 +230,7 @@ TEST(MetaprogrammingTest, TupleMap_mapsToDifferentTypes) { TEST(MetaprogrammingTest, TupleMap_differentiatesLRValueReferences) { struct Mapper { + // NOLINTNEXTLINE(*move*) std::string operator()(std::string&& a) const { return "moved"; } diff --git a/c10/test/util/logging_test.cpp b/c10/test/util/logging_test.cpp index ca1fab0528c..5798b37c18e 100644 --- a/c10/test/util/logging_test.cpp +++ b/c10/test/util/logging_test.cpp @@ -23,6 +23,7 @@ TEST(LoggingTest, TestEnforceFalse) { CAFFE_ENFORCE(false, "This throws."); // This should never be triggered. ADD_FAILURE(); + // NOLINTNEXTLINE(*catch*) } catch (const ::c10::Error&) { } std::swap(FLAGS_caffe2_use_fatal_for_enforce, kFalse); diff --git a/c10/util/Bitset.h b/c10/util/Bitset.h index 1acb89afd92..782cefbd922 100644 --- a/c10/util/Bitset.h +++ b/c10/util/Bitset.h @@ -57,6 +57,7 @@ struct bitset final { // Call the given functor with the index of each bit that is set template + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) void for_each_set_bit(Func&& func) const { bitset cur = *this; size_t index = cur.find_first_set(); diff --git a/c10/util/signal_handler.cpp b/c10/util/signal_handler.cpp index e457238713c..7132f08588c 100644 --- a/c10/util/signal_handler.cpp +++ b/c10/util/signal_handler.cpp @@ -37,6 +37,7 @@ std::atomic sighupCount(0); std::atomic hookedUpCount(0); void handleSignal(int signal) { + // NOLINTNEXTLINE(bugprone-switch-missing-default-case) switch (signal) { // TODO: what if the previous handler uses sa_sigaction? case SIGHUP: diff --git a/tools/linter/adapters/s3_init_config.json b/tools/linter/adapters/s3_init_config.json index 5a0ceb85ff3..94bd7b679b5 100644 --- a/tools/linter/adapters/s3_init_config.json +++ b/tools/linter/adapters/s3_init_config.json @@ -30,8 +30,8 @@ "hash": "4ed664cf50bb9fddec2d4170b3d7bbe0135dc5648acbd620b61c8d25a5a2fdb7" }, "Linux": { - "download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/15.0.6/clang-tidy", - "hash": "8defeb3a2698caca60251f9d682bc08374f1a37eec77d515533affdd03f93add" + "download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/17.0.6/clang-tidy", + "hash": "a93110b0d58b430bb7ce86c8497f2528e1d44eed25d546557e7ec45c44ddfeb7" } }, "actionlint": { diff --git a/torch/csrc/autograd/python_nn_functions.h b/torch/csrc/autograd/python_nn_functions.h index 54dc6e1b293..2fc4f4727e3 100644 --- a/torch/csrc/autograd/python_nn_functions.h +++ b/torch/csrc/autograd/python_nn_functions.h @@ -1,5 +1,5 @@ #pragma once - +#include namespace torch::autograd { void initNNFunctions(PyObject* module);