Skip to content

Commit 85b106f

Browse files
committed
feat: add clang-tidy to CI
1 parent c046b17 commit 85b106f

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

.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

include/tvm/ffi/container/array.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class Array : public ObjectRef {
447447
* \tparam IterType The type of iterator
448448
*/
449449
template <typename IterType>
450-
Array(IterType first, IterType last) {
450+
Array(IterType first, IterType last) { // NOLINT(performance-unnecessary-value-param)
451451
static_assert(is_valid_iterator_v<T, IterType>,
452452
"IterType cannot be inserted into a tvm::Array<T>");
453453
Assign(first, last);
@@ -817,7 +817,7 @@ class Array : public ObjectRef {
817817
* \tparam IterType The type of iterator
818818
*/
819819
template <typename IterType>
820-
void Assign(IterType first, IterType last) {
820+
void Assign(IterType first, IterType last) { // NOLINT(performance-unnecessary-value-param)
821821
int64_t cap = std::distance(first, last);
822822
if (cap < 0) {
823823
TVM_FFI_THROW(ValueError) << "cannot construct an Array of negative size";

0 commit comments

Comments
 (0)