llvm / llvm/llvm-project

.clang-format-ignore is not reusable

Open
#158,538 2 comments 3 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This is a split off from https://github.com/clangd/clangd/issues/2476#issuecomment-3290327107
Users of clangd want to indicate that new files are formatted and old files are left alone.

Clang-format 18 added support for .clang-format-ignore and clang 20 fixed issues and added blob support regarding it. Unfortunately, most/all of the code of this feature is directly called from the main function instead of being part of the format library. As such, this feature is only available when using the clang-format executable and not when doing formatting any other way, like clangd does.

Given that it is called directly before `clang::format::format(FileName, FailOnIncompleteFormat);`, this should easily be moved inside that function.

A concern:
- can we apply this to every format or should it be optional to ignore this file?

Contributor guide

Open the contributing guide

Research direction

Start by tracing the .clang-format-ignore handling from the clang-format executable's main function to clang::format::format(FileName, FailOnIncompleteFormat). Check how clangd and other formatting callers reach the format library. Done means the ignore behavior is reusable outside the executable, with the issue's concern about whether it should be optional resolved and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.