<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/115011>115011</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [format] clang-format-18 flip-flops on some macro code
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          flichtenheld
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VM-PqzYQ_mvMZZTImADJgcPuSyNFVd9entTjysAYu2s8yDabR__6yoS3zbaHHtoiZBgxP7755mNkCGZwiA0rn1l5zuQcNflGWdPpiE6j7bOW-qX5phEUWUs34wboqEfGz4w_bWfFt3s1WyIL6JLX6_TWhZyJIxMnYPXz5i-KHpVxCL88_fzT6_nKxPH75vH1en5lomCi-M7EF1iPYH5HUpsTq8-PtQEuLy-giO4tsOJHjQ-3z-DuZyfngAE6K92wU-RHGXf5ESKBsmbaKUsTkIO4tp2-RuOGPfxqooYelZxtBJqiIRdWJ4oaPYQoI4IlegtgzRtC1Caw4ul_4erfXKz8srHH6mf4R8rhP-H8GkHam1wChJuJncYAytO48kwPLCYu4KbRgUc_O7cq7mFQ-y0daPmOjok6guziLK1dQNHsepBugRAXi0B-GxNELSOM8g3vA5s8tRZHGAjkTS77R6DftAlgAkjwOHgMIcUb91e1JJqu0Mk7BI-Tp37u8FP6WxLMLq8TEJTeGvTwjj5lDJ9qXl1EjyHJzC5gFCw0Q6elGxBYxS8vL6ziiSdWcePiajzUkTYQDITh3g18pQhh9olHGbfeUbqQMLdzXGNtEpVUEf1qjrLzBKvWzMrY9op2gcmmsUnwZBE0etxnfVP0p-IkM2zyuuBHkVf8lOlGHIseS6EOouwqVSku-rw61K2SLS9O1SEzjeDikOe8zMtDdTju61qVp6JH3mNfy56zA8dRGru39n3ckx8yE8KMTZ6XPM8zK1u0Yd1YQjyOhAmRdphvUtyunYfADtyaEMOfmaKJdt12W0h5_tsO-FgAISkz0PiDmqTLbPa20TFO628tLkxcBhP13O47Gpm4pELbYzd5-g27yMRlxR-YuGwtvDfijwAAAP__Vnmqeg">