Skip to content

chore: Fix clang-tidy warnings#197

Merged
tqchen merged 1 commit into
apache:mainfrom
junrushao:2025-10-27/clang-tidy-next
Oct 28, 2025
Merged

chore: Fix clang-tidy warnings#197
tqchen merged 1 commit into
apache:mainfrom
junrushao:2025-10-27/clang-tidy-next

Conversation

@junrushao

@junrushao junrushao commented Oct 28, 2025

Copy link
Copy Markdown
Member

Following #78, this PR addresses new warnings from clang-tidy.

After this PR being merged, PR #95 will run clang-tidy tests per-commit to main branch to make sure it always passes.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @junrushao, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on resolving and managing clang-tidy warnings throughout the codebase, following up on a previous effort. The changes primarily involve strategically placing NOLINT directives to suppress warnings that are either false positives or where the current code structure is intentionally maintained. Additionally, some warnings led to minor code adjustments, such as optimizing parameter passing to const references and simplifying explicit type casting, contributing to a cleaner and more robust codebase without altering its core functionality.

Highlights

  • Clang-Tidy Warning Suppressions: Introduced NOLINT directives to suppress various clang-tidy warnings, including clang-analyzer-security.ArrayBound, modernize-macro-to-enum, performance-unnecessary-value-param, and bugprone-reserved-identifier, across several header and source files.
  • Parameter Passing Optimization: Addressed a clang-tidy warning by changing a parameter from pass-by-value to pass-by-const-reference in include/tvm/ffi/reflection/registry.h for improved performance.
  • Casting Simplification: Simplified reinterpret_cast operations for function pointers in src/ffi/testing/testing.cc, making the code cleaner.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request addresses several clang-tidy warnings. Most changes involve adding NOLINT comments to suppress warnings that appear to be false positives, particularly for iterator parameters and C-style macros. A good change is the switch from NOLINTNEXTLINE to NOLINTBEGIN/NOLINTEND blocks for better scoping. There are also correct code fixes, such as passing an ObjectRef-derived type by const reference instead of by value to improve performance, and removing an unnecessary reinterpret_cast to void*. The changes are sound and improve the codebase. I have one minor suggestion regarding a leftover comment.

Comment thread src/ffi/testing/testing.cc Outdated
"Class must be derived from ObjectRef or Object");
if constexpr (std::is_base_of_v<ObjectRef, Class>) {
auto fwrap = [func](const Class target, Args... params) -> R {
auto fwrap = [func](const Class& target, Args... params) -> R {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@tqchen This line may be a little concerning. Could you take a look just in case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is probably fine.

Comment thread src/ffi/testing/testing.cc Outdated
.def("testing.get_mlir_add_one_c_symbol",
[]() {
return reinterpret_cast<int64_t>(reinterpret_cast<void*>(_mlir_add_one_c_symbol));
[]() { //

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

in some systems it is important to first cast function pointer to void* then cast to int64_t

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see...Updated!

@junrushao junrushao force-pushed the 2025-10-27/clang-tidy-next branch from d03f261 to 215f4ad Compare October 28, 2025 02:36
@tqchen tqchen merged commit d5d2d12 into apache:main Oct 28, 2025
7 checks passed
junrushao added a commit that referenced this pull request Oct 28, 2025
Depends on #197. This PR adds clang-tidy to per-commit tests on branch
`main` to detect potential breaks.
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