Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions .github/workflows/pr-code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
jobs:
code_formatter:
runs-on: ubuntu-24.04
container:
image: 'ghcr.io/llvm/ci-ubuntu-24.04:latest'
timeout-minutes: 30
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
Expand All @@ -38,31 +40,21 @@ jobs:
run: |
echo "Formatting files:"
echo "$CHANGED_FILES"

# The clang format version should always be upgraded to the first version
# of a release cycle (x.1.0) or the last version of a release cycle, or
# if there have been relevant clang-format backports.
- name: Install clang-format
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
with:
clangformat: 21.1.0

- name: Setup Python env
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'

- name: Create python venv
run: |
python -m venv venv

- name: Install python dependencies
run: pip install -r llvm/utils/git/requirements_formatting.txt
run: venv/bin/pip install -r llvm/utils/git/requirements_formatting.txt

- name: Run code formatter
env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
# Create an empty comments file so the pr-write job doesn't fail.
run: |
. venv/bin/activate &&
echo "[]" > comments &&
python ./llvm/utils/git/code-format-helper.py \
--write-comment-to-file \
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/clang-tidy/ClangTidy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ class ErrorReporter {
const llvm::StringMap<Replacements> &Fix) {
for (const auto &FileAndReplacements : Fix) {
for (const auto &Repl : FileAndReplacements.second) {
if (!Repl.isApplicable())
continue;
if (!Repl.isApplicable()) continue;
FileByteRange FBR;
FBR.FilePath = Repl.getFilePath().str();
FBR.FileOffset = Repl.getOffset();
Expand Down
6 changes: 2 additions & 4 deletions llvm/utils/git/code-lint-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,8 @@ def run_clang_tidy(changed_files: List[str], args: LintArgs) -> Optional[str]:
proc = subprocess.run(
tidy_diff_cmd,
input=diff_content,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=False,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
text=True, check=False,
)

return clean_clang_tidy_output(proc.stdout.strip())
Expand Down
Loading