llvm / llvm/llvm-project

[clang-format] Multi-line macro doesn't respect `ColumnLimit: 0`

Open
#161,677 1 comment 0 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I noticed that multi-line macros don't respect the `ColumnLimit: 0` setting.

So the following:

```C
#define PACK_REFS_OPTS(spaces) \
"[--all] [--no-prune] [--auto] [--include ] [--exclude ]\n" \
spaces "[--required]"
```

is always requested to be changed like:

```diff
#define PACK_REFS_OPTS_SPACES_14 " "
#define PACK_REFS_OPTS_SPACES_18 " "
-#define PACK_REFS_OPTS(spaces) \
- "[--all] [--no-prune] [--auto] [--include ] [--exclude ]\n" \
- spaces "[--required]"
+#define PACK_REFS_OPTS(spaces) \
+ "[--all] [--no-prune] [--auto] [--include ] [--exclude " \
+ "]\n" spaces "[--required]"
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the shown multi-line macro with clang-format and ColumnLimit: 0, then trace the formatting path for macro contents. Done means clang-format preserves the macro's existing line layout when that setting disables the column limit.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.