Skip to content

Commit 6f73b97

Browse files
committed
feat: add clang-tidy to CI
1 parent 789e9e5 commit 6f73b97

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/ci_test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,21 @@ jobs:
5252
steps:
5353
- uses: actions/checkout@v5
5454
with:
55+
submodules: recursive
5556
fetch-depth: 0
5657
fetch-tags: true
5758
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
59+
- name: Set up uv
60+
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
61+
- uses: ./.github/actions/detect-env-vars
62+
id: env_vars
63+
- name: Run clang-tidy
64+
run: |
65+
uv run --no-project --with "clang-tidy==21.1.1" \
66+
python tests/lint/clang_tidy_precommit.py \
67+
--build-dir=build-pre-commit \
68+
--jobs=${{ steps.env_vars.outputs.cpu_count }} \
69+
./src/ ./include ./tests
5870
5971
doc:
6072
needs: [lint, prepare]

include/tvm/ffi/base_details.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ TVM_FFI_INLINE uint64_t StableHashCombine(uint64_t key, const T& value) {
200200
* \return the hash value.
201201
*/
202202
TVM_FFI_INLINE uint64_t StableHashBytes(const void* data_ptr, size_t size) {
203+
// NOLINTBEGIN(clang-analyzer-security.ArrayBound)
203204
const char* data = reinterpret_cast<const char*>(data_ptr);
204205
const constexpr uint64_t kMultiplier = 1099511628211ULL;
205206
const constexpr uint64_t kMod = 2147483647ULL;
@@ -215,14 +216,12 @@ TVM_FFI_INLINE uint64_t StableHashBytes(const void* data_ptr, size_t size) {
215216
// if alignment requirement is met, directly use load
216217
if (reinterpret_cast<uintptr_t>(it) % 8 == 0) {
217218
for (; it + 8 <= end; it += 8) {
218-
// NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)
219219
u.b = *reinterpret_cast<const uint64_t*>(it);
220220
result = (result * kMultiplier + u.b) % kMod;
221221
}
222222
} else {
223223
// unaligned version
224224
for (; it + 8 <= end; it += 8) {
225-
// NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)
226225
u.a[0] = it[0];
227226
u.a[1] = it[1];
228227
u.a[2] = it[2];
@@ -277,6 +276,7 @@ TVM_FFI_INLINE uint64_t StableHashBytes(const void* data_ptr, size_t size) {
277276
}
278277
result = (result * kMultiplier + u.b) % kMod;
279278
}
279+
// NOLINTEND(clang-analyzer-security.ArrayBound)
280280
return result;
281281
}
282282

include/tvm/ffi/c_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@
5656
#define TVM_FFI_DLL_EXPORT __attribute__((visibility("default")))
5757
#endif
5858

59+
// NOLINTBEGIN(modernize-macro-to-enum)
5960
/*! \brief TVM FFI major version. */
6061
#define TVM_FFI_VERSION_MAJOR 0
6162
/*! \brief TVM FFI minor version. */
6263
#define TVM_FFI_VERSION_MINOR 1
6364
/*! \brief TVM FFI patch version. */
6465
#define TVM_FFI_VERSION_PATCH 1
66+
// NOLINTEND(modernize-macro-to-enum)
6567

6668
#ifdef __cplusplus
6769
extern "C" {

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)