Skip to content

feat: enforce Google-based clang-format style and add style checker#156

Open
chen2021673 wants to merge 1 commit into
masterfrom
format
Open

feat: enforce Google-based clang-format style and add style checker#156
chen2021673 wants to merge 1 commit into
masterfrom
format

Conversation

@chen2021673
Copy link
Copy Markdown
Contributor

@chen2021673 chen2021673 commented May 21, 2026

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 重新分组排序)

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.
#include <nccl.h>
#include <vector>

#include <nccl.h>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c 语言系统库头文件应当放在 c++标准库头文件上一个分组。

@@ -1,3 +1,5 @@
#include "infini_train/include/autograd/linear.h"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个不是配套头文件,不需要放首行,以及理论上 kernel 层不应当引用 autograd 层头文件。

#include <memory>
#include <tuple>

#include <fcntl.h>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c 语言系统库头文件,位置不对。

Comment thread scripts/format.py
class _NoColor:
BLACK = RED = GREEN = YELLOW = BLUE = MAGENTA = CYAN = WHITE = RESET_ALL = ""

Fore = Style = _NoColor()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里没必要这么改吧

Comment thread .clang-format
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件不要动。

Comment thread CMakeLists.txt
add_executable(test_maca_allocator test/runtime/test_maca_allocator.cc)
link_infini_train_exe(test_maca_allocator)
endif()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants