Skip to content

Commit 7a65d3f

Browse files
committed
feat: add clang-tidy to CI
1 parent c046b17 commit 7a65d3f

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/ci_test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,20 @@ jobs:
5050
runs-on: ubuntu-latest
5151
steps:
5252
- uses: actions/checkout@v4
53+
with:
54+
submodules: recursive
5355
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
56+
- name: Set up uv
57+
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
58+
- uses: ./.github/actions/detect-env-vars
59+
id: env_vars
60+
- name: Run clang-tidy
61+
run: |
62+
uv run --no-project --with "clang-tidy==21.1.1" \
63+
python tests/lint/clang_tidy_precommit.py \
64+
--build-dir=build-pre-commit \
65+
--jobs=${{ steps.env_vars.outputs.cpu_count }} \
66+
./src/ ./include ./tests
5467
5568
doc:
5669
needs: [lint, prepare]

include/tvm/ffi/base_details.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ TVM_FFI_INLINE uint64_t StableHashCombine(uint64_t key, const T& value) {
196196
* \return the hash value.
197197
*/
198198
TVM_FFI_INLINE uint64_t StableHashBytes(const void* data_ptr, size_t size) {
199+
// NOLINTBEGIN(clang-analyzer-security.ArrayBound)
199200
const char* data = reinterpret_cast<const char*>(data_ptr);
200201
const constexpr uint64_t kMultiplier = 1099511628211ULL;
201202
const constexpr uint64_t kMod = 2147483647ULL;
@@ -211,14 +212,12 @@ TVM_FFI_INLINE uint64_t StableHashBytes(const void* data_ptr, size_t size) {
211212
// if alignment requirement is met, directly use load
212213
if (reinterpret_cast<uintptr_t>(it) % 8 == 0) {
213214
for (; it + 8 <= end; it += 8) {
214-
// NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)
215215
u.b = *reinterpret_cast<const uint64_t*>(it);
216216
result = (result * kMultiplier + u.b) % kMod;
217217
}
218218
} else {
219219
// unaligned version
220220
for (; it + 8 <= end; it += 8) {
221-
// NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)
222221
u.a[0] = it[0];
223222
u.a[1] = it[1];
224223
u.a[2] = it[2];
@@ -273,6 +272,7 @@ TVM_FFI_INLINE uint64_t StableHashBytes(const void* data_ptr, size_t size) {
273272
}
274273
result = (result * kMultiplier + u.b) % kMod;
275274
}
275+
// NOLINTEND(clang-analyzer-security.ArrayBound)
276276
return result;
277277
}
278278

0 commit comments

Comments
 (0)