Issue 115011
Summary [format] clang-format-18 flip-flops on some macro code
Labels clang-format
Assignees
Reporter flichtenheld
    The following code

```
bool encode_pkcs1() {
#define MAKE_DI(x) {NID_##x, x, sizeof(x)}

  FOO foo[];
}
```

causes clang-format-18 to flip-flop on the formatting. With default options the other state looks like this:

```
bool encode_pkcs1() {
#define MAKE_DI(x)                                                             \
 { NID_##x, x, sizeof(x) }

  FOO foo[];
}
```

It always switches from on to the other code when rerunning clang-format.
I haven't actually found any style or option that makes the problem go away.

This is a regression in clang-format-18, I can't reproduce the problem with -17 or earlier versions.

Interestingly if you change `FOO` to `int` the problem also goes away. Not sure what that means, but the line after the macro definition definitely plays a role here.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to