feat: enforce Google-based clang-format style and add style checker#156
Open
chen2021673 wants to merge 1 commit into
Open
feat: enforce Google-based clang-format style and add style checker#156chen2021673 wants to merge 1 commit into
chen2021673 wants to merge 1 commit into
Conversation
Switch .clang-format from LLVM to Google base style with project-specific rules (include regrouping, pointer alignment, brace insertion). Add scripts/style_check.py for additional style enforcement and integrate it into the CI format-check workflow.
kilinchange
requested changes
May 23, 2026
| #include <nccl.h> | ||
| #include <vector> | ||
|
|
||
| #include <nccl.h> |
Collaborator
There was a problem hiding this comment.
c 语言系统库头文件应当放在 c++标准库头文件上一个分组。
| @@ -1,3 +1,5 @@ | |||
| #include "infini_train/include/autograd/linear.h" | |||
Collaborator
There was a problem hiding this comment.
这个不是配套头文件,不需要放首行,以及理论上 kernel 层不应当引用 autograd 层头文件。
| #include <memory> | ||
| #include <tuple> | ||
|
|
||
| #include <fcntl.h> |
| class _NoColor: | ||
| BLACK = RED = GREEN = YELLOW = BLUE = MAGENTA = CYAN = WHITE = RESET_ALL = "" | ||
|
|
||
| Fore = Style = _NoColor() |
| add_executable(test_maca_allocator test/runtime/test_maca_allocator.cc) | ||
| link_infini_train_exe(test_maca_allocator) | ||
| endif() | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
将 .clang-format 基础风格从 LLVM 切换为 Google,并增加项目定制规则(include 分组排序、指针右对齐、强制大括号等)
新增 scripts/style_check.py 自定义风格检查脚本,覆盖 CJK 字符检测、thread_local 命名规范等 clang-format 无法覆盖的规则
CI workflow 增加 style check 步骤,并以 advisory 模式集成 IWYU (include-what-you-use) 检查
对现有 29 个源文件按新规则进行格式化(主要是 include 重新分组排序)