mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Bump Clang-tidy to 19.1.4 (#148648)
Because Clang-tidy 19 has more powerful clang-analyzer checks to detect subtle bugs. New checks such as misc-use-internal-linkage can help identify potential static variables or functions, thus reducing binary sizes. Some new checks are disabled temporarily for later enabling. Additional warnings have been fixed or suppressed. Pull Request resolved: https://github.com/pytorch/pytorch/pull/148648 Approved by: https://github.com/Skylion007
This commit is contained in:
@ -12,6 +12,7 @@ bugprone-*,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-lambda-function-name,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-return-const-ref-from-parameter,
|
||||
-bugprone-swapped-arguments,
|
||||
clang-analyzer-core.*,
|
||||
clang-analyzer-cplusplus.*,
|
||||
@ -24,6 +25,7 @@ cppcoreguidelines-*,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-interfaces-global-init,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-macro-to-enum,
|
||||
-cppcoreguidelines-owning-memory,
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
@ -46,6 +48,7 @@ misc-*,
|
||||
-misc-no-recursion,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-misc-unused-using-decls,
|
||||
-misc-use-internal-linkage,
|
||||
modernize-*,
|
||||
-modernize-macro-to-enum,
|
||||
-modernize-return-braced-init-list,
|
||||
@ -55,6 +58,7 @@ modernize-*,
|
||||
-modernize-use-trailing-return-type,
|
||||
-modernize-use-nodiscard,
|
||||
performance-*,
|
||||
-performance-enum-size,
|
||||
readability-container-size-empty,
|
||||
readability-delete-null-pointer,
|
||||
readability-duplicate-include
|
||||
|
@ -272,6 +272,7 @@ MapAllocator::MapAllocator(WithFd, std::string_view filename, int fd, int flags,
|
||||
}
|
||||
} else {
|
||||
fd = fd_;
|
||||
TORCH_INTERNAL_ASSERT(fd >= 0);
|
||||
}
|
||||
|
||||
struct stat file_stat{};
|
||||
|
@ -12,6 +12,7 @@ using namespace c10;
|
||||
static std::vector<at::Tensor> get_tensor_vector() {
|
||||
std::vector<at::Tensor> tensors;
|
||||
const size_t SIZE = 5;
|
||||
tensors.reserve(SIZE);
|
||||
for (size_t i = 0; i < SIZE; i++) {
|
||||
tensors.emplace_back(at::empty({0}));
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ SymNode SymInt::toSymNode() const {
|
||||
SymInt::SymInt(SymNode sin_sp) {
|
||||
TORCH_CHECK_ALWAYS_SHOW_CPP_STACKTRACE(
|
||||
sin_sp->is_int(), "SymInt::SymInt sin_sp->is_int()");
|
||||
auto ptr = static_cast<uint64_t>(
|
||||
reinterpret_cast<uintptr_t>(static_cast<void*>(sin_sp.release())));
|
||||
auto ptr =
|
||||
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(sin_sp.release()));
|
||||
auto rep = (ptr & ~MASK) | IS_SYM;
|
||||
data_ = static_cast<int64_t>(rep);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace c10::detail {
|
||||
|
||||
template <typename T>
|
||||
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||
T maybe_wrap_dim_slow(T dim, T dim_post_expr, bool wrap_scalar) {
|
||||
TORCH_CHECK_INDEX(
|
||||
dim_post_expr >= 0, "Rank cannot be negative but got ", dim_post_expr);
|
||||
|
@ -143,6 +143,7 @@ size_t CUDAAllocatorConfig::parseRoundUpPower2Divisions(
|
||||
if (++i < config.size()) {
|
||||
if (std::string_view(config[i]) == "[") {
|
||||
size_t last_index = 0;
|
||||
// NOLINTNEXTLINE(bugprone-inc-dec-in-conditions)
|
||||
while (++i < config.size() && std::string_view(config[i]) != "]") {
|
||||
const std::string& val1 = config[i];
|
||||
size_t val2 = 0;
|
||||
|
@ -313,7 +313,9 @@ TEST(DispatchKeySet, IteratorBasicOps) {
|
||||
ASSERT_TRUE(full_set.begin() != full_set.end());
|
||||
|
||||
// Increment Ops
|
||||
// NOLINTNEXTLINE(bugprone-inc-dec-in-conditions)
|
||||
ASSERT_TRUE(full_set.begin() == full_set.begin()++);
|
||||
// NOLINTNEXTLINE(bugprone-inc-dec-in-conditions)
|
||||
ASSERT_TRUE(full_set.begin() != ++full_set.begin());
|
||||
}
|
||||
|
||||
@ -430,9 +432,13 @@ TEST(DispatchKeySet, TestFunctionalityDispatchKeyToString) {
|
||||
k == DispatchKey::StartOfAutogradFunctionalityBackends)
|
||||
continue;
|
||||
auto res = std::string(toString(k));
|
||||
if (i > 0) {
|
||||
ASSERT_TRUE(res.find("Unknown") == std::string::npos)
|
||||
<< i << " (before is " << toString(static_cast<DispatchKey>(i - 1))
|
||||
<< ")";
|
||||
} else {
|
||||
ASSERT_TRUE(res.find("Unknown") == std::string::npos) << i;
|
||||
}
|
||||
ASSERT_TRUE(seen_strings.count(res) == 0);
|
||||
seen_strings.insert(res);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ TEST(LazyTest, OptimisticLazy) {
|
||||
std::vector<std::thread> threads;
|
||||
std::atomic<std::string*> address = nullptr;
|
||||
|
||||
threads.reserve(kNumThreads);
|
||||
for (size_t i = 0; i < kNumThreads; ++i) {
|
||||
threads.emplace_back([&] {
|
||||
auto* p = &s.ensure(factory);
|
||||
|
@ -61,11 +61,7 @@ class basic_string_view final {
|
||||
constexpr basic_string_view(const basic_string_view&) noexcept = default;
|
||||
|
||||
constexpr basic_string_view& operator=(
|
||||
const basic_string_view& rhs) noexcept {
|
||||
begin_ = rhs.begin_;
|
||||
size_ = rhs.size_;
|
||||
return *this;
|
||||
}
|
||||
const basic_string_view& rhs) noexcept = default;
|
||||
|
||||
constexpr operator ::std::basic_string_view<CharT>() const {
|
||||
return ::std::basic_string_view<CharT>(data(), size());
|
||||
|
@ -22,16 +22,16 @@
|
||||
},
|
||||
"clang-tidy": {
|
||||
"Darwin-i386": {
|
||||
"download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/macos-i386/15.0.6/clang-tidy",
|
||||
"hash": "11c9234155dd5b7aec8cf46ea9629401c4432576615b6eff2a5a4c5e3f9e6504"
|
||||
"download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/macos-i386/19.1.4/clang-tidy",
|
||||
"hash": "7b5da17d3f8b1c18c77d043999f05293f43402affb16de15dfcb276971984a3e"
|
||||
},
|
||||
"Darwin-arm": {
|
||||
"download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/macos-arm/15.0.6/clang-tidy",
|
||||
"hash": "4ed664cf50bb9fddec2d4170b3d7bbe0135dc5648acbd620b61c8d25a5a2fdb7"
|
||||
"download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/macos-arm/19.1.4/clang-tidy",
|
||||
"hash": "04243f4044fe6d95f6d51d15be803331c3cbb61f2d8fcfeba5a5dec1e7ae6dfb"
|
||||
},
|
||||
"Linux": {
|
||||
"download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/17.0.6/clang-tidy",
|
||||
"hash": "a93110b0d58b430bb7ce86c8497f2528e1d44eed25d546557e7ec45c44ddfeb7"
|
||||
"download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/19.1.4/clang-tidy",
|
||||
"hash": "5637bd0fca665d2797926fedf53ca5ad4655bb9dbed1e1c8654c8e032ce1e7a8"
|
||||
}
|
||||
},
|
||||
"actionlint": {
|
||||
|
Reference in New Issue
Block a user