[libc-commits] [libc] [libc] Improve the state of the lint rules (PR #135278)
via libc-commits
libc-commits at lists.llvm.org
Thu Apr 10 16:15:46 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Michael Jones (michaelrj-google)
<details>
<summary>Changes</summary>
The goal of this change is to update the rules such that we can run the
linter and get a clean result. For testing purposes set
`-DLLVM_LIBC_ENABLE_LINTING=ON` and run `ninja -j 1 -k 0 libc-lint`, or
pick a single `__lint__` target, such as `ninja
libc.src.stdio.sprintf.__lint__`.
BEFORE MERGING:
remove --fix from the lint target
---
Full diff: https://github.com/llvm/llvm-project/pull/135278.diff
4 Files Affected:
- (modified) libc/.clang-tidy (+8)
- (modified) libc/cmake/modules/LLVMLibCObjectRules.cmake (+1-1)
- (added) libc/include/.clang-tidy (+3)
- (modified) libc/src/.clang-tidy (+1-1)
``````````diff
diff --git a/libc/.clang-tidy b/libc/.clang-tidy
index dbde88928ee63..bd09aae981ba9 100644
--- a/libc/.clang-tidy
+++ b/libc/.clang-tidy
@@ -6,6 +6,8 @@ CheckOptions:
value: CamelCase
- key: readability-identifier-naming.StructCase
value: aNy_CasE
+ - key: readability-identifier-naming.StructIgnoredRegexp
+ value: "_?(_[A-Za-z0-9]+)*"
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.MemberIgnoredRegexp
@@ -14,6 +16,10 @@ CheckOptions:
value: lower_case
- key: readability-identifier-naming.VariableIgnoredRegexp
value: "_?(_[A-Za-z0-9]+)*"
+ - key: readability-identifier-naming.ParameterCase
+ value: lower_case
+ - key: readability-identifier-naming.ParameterIgnoredRegexp
+ value: "_?(_[A-Za-z0-9]+)*"
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.FunctionIgnoredRegexp
@@ -26,6 +32,8 @@ CheckOptions:
value: UPPER_CASE
- key: readability-identifier-naming.ConstexprVariableCase
value: UPPER_CASE
+ - key: readability-identifier-naming.ConstexprVariableIgnoredRegexp
+ value: "is(_[A-Za-z0-9]+)*_v"
- key: readability-identifier-naming.ConstexprFunctionCase
value: lower_case
- key: readability-identifier-naming.GetConfigPerFile
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 142778d9ea1cc..c8a20341ff74f 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -355,7 +355,7 @@ function(create_entrypoint_object fq_target_name)
# Until this is fixed upstream, we use -fno-caret-diagnostics to surpress
# these.
COMMAND ${LLVM_LIBC_CLANG_TIDY}
- "--extra-arg=-fno-caret-diagnostics" --quiet
+ "--extra-arg=-fno-caret-diagnostics" --quiet --fix
# Path to directory containing compile_commands.json
-p ${PROJECT_BINARY_DIR}
${ADD_ENTRYPOINT_OBJ_SRCS}
diff --git a/libc/include/.clang-tidy b/libc/include/.clang-tidy
new file mode 100644
index 0000000000000..a6c02dd90e4d2
--- /dev/null
+++ b/libc/include/.clang-tidy
@@ -0,0 +1,3 @@
+InheritParentConfig: false
+Checks: ''
+HeaderFilterRegex: '.*'
diff --git a/libc/src/.clang-tidy b/libc/src/.clang-tidy
index 1c79b1cf6aae6..7e97dac43d38a 100644
--- a/libc/src/.clang-tidy
+++ b/libc/src/.clang-tidy
@@ -4,4 +4,4 @@ HeaderFilterRegex: '.*'
WarningsAsErrors: 'llvmlibc-*'
CheckOptions:
- key: llvmlibc-restrict-system-libc-headers.Includes
- value: '-*, linux/*, asm/*.h, asm-generic/*.h'
+ value: '-*, linux/*, asm/*.h, asm-generic/*.h. sys/syscall.h'
``````````
</details>
https://github.com/llvm/llvm-project/pull/135278
More information about the libc-commits
mailing list