Skip to content

Conversation

dorde-antic
Copy link
Contributor

Motivation

Resolves https://github.com/ROCm/rocMLIR-internal/issues/1882

Technical Details

Test Plan

Test Result

Submission Checklist

@umangyadav umangyadav requested a review from Copilot October 10, 2025 13:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a Git pre-commit hook for clang-formatting C/C++ files. It adds a Python utility to handle clang-format operations and integrates it into the existing pre-commit hook workflow.

  • Adds a new Python utility (clangformat.py) that wraps git-clang-format functionality
  • Updates the pre-commit hook to run clang-format on C/C++ files in addition to the existing yapf formatting for Python files
  • Adds error handling and validation for required tools (yapf and clang-format)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
mlir/utils/widgets/clangformat.py New Python utility providing clang-format integration with Git workflow
.githooks/pre-commit Updated pre-commit hook to include clang-format execution and improved tool validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

import argparse
import subprocess

CLANG_FORMAT_PATH = '/opt/rocm/llvm/bin'
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

The hardcoded path '/opt/rocm/llvm/bin' makes this code non-portable across different environments. Consider making this configurable through environment variables or command-line arguments, with this as a fallback default.

Copilot uses AI. Check for mistakes.

Comment on lines +39 to +40
return subprocess.check_output(['git', 'rev-parse', '--show-toplevel'],
text=True).strip()
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

Git commands lack error handling. If git is not available or not in a git repository, subprocess.check_output will raise CalledProcessError with unclear error messages for users.

Copilot uses AI. Check for mistakes.

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.

1 participant