From 99f5a85a09596b3b2c83329f5e686ce4d8775efb Mon Sep 17 00:00:00 2001 From: cyy Date: Mon, 10 Jun 2024 23:49:58 +0000 Subject: [PATCH] [Clang Tidy] Fix misc-header-include-cycle errors in clang-tidy and ignore some files (#127233) Since there are such cycles in libfmt and PyTorch, which are detected by clang-tidy. ``` /home/cyy/pytorch/third_party/fmt/include/fmt/format-inl.h:25:10: error: circular header file dependency detected while including 'format.h', please check the include path [misc-header-include-cycle,-warnings-as-errors] 25 | #include "format.h" | ^ /home/cyy/pytorch/third_party/fmt/include/fmt/format.h:4530:12: note: 'format-inl.h' included from here 4530 | # include "format-inl.h" ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/127233 Approved by: https://github.com/ezyang --- .clang-tidy | 2 ++ torch/csrc/jit/python/python_custom_class.cpp | 1 + torch/csrc/jit/python/python_custom_class.h | 1 - 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index fef154d4b0c1f3..1f7521ce76005d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -62,4 +62,6 @@ 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' ... diff --git a/torch/csrc/jit/python/python_custom_class.cpp b/torch/csrc/jit/python/python_custom_class.cpp index 55cde36c0e62c4..bf9e516566e5b7 100644 --- a/torch/csrc/jit/python/python_custom_class.cpp +++ b/torch/csrc/jit/python/python_custom_class.cpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/torch/csrc/jit/python/python_custom_class.h b/torch/csrc/jit/python/python_custom_class.h index d7cff488f27311..1033fc008f2721 100644 --- a/torch/csrc/jit/python/python_custom_class.h +++ b/torch/csrc/jit/python/python_custom_class.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include