<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJztmdtzqjgcx_8afMnoKFhbH3igSK27eFlEzzlPDkLQ7CA4BNvxvz8BBUnD1UtnZ-cwTk3C75aLfL7WtWcdRQ36B9dF7gaYjuFumrbn74wAdATA8S-GawHScaCBAxBsIXDChg0_wd5Hng8-oI-R52KO7wPPBYbjQ8M6glOMAFrA9CwINugDYmAAC9k29KEbAMPFn9BvgSG543LtAdeWzn977dPL5PjX8HUa5d_IC3CCjF205wSFcuEFC9rIhUAZqytZnU6UlfJzps1J_T_DwjIv7kk-uYcdYvYizeej4STXvth5OdL0haSuqgRhnOe6tpD11VJSF0pZfrbswSD0CZvj0WQxTzoLNW4ORks2LBNI1WN7VYlbw2RsmIwp_8StCVUtE1CWJklp8lRLvKZ6_iSZIItkUuUX6zxTq_pmla-qFX0znN8V-e9rMy8VWT-t1xXO49TGj887fzoc6c5s-kOhMzCB0vaseYVKUttfaTbsIuqaNJnPpvPk7FEDFRZSlpID_H5u16pgKWmXEzyZJ8EGiqa85URjP96L19iPNFf5nnkB3kaKmixl1ImDJAPydDwr3k5lPNN_rcaSro3yH4p5zuePwmlXf5XvJZv9chbmM6n8KcueBUUlT1dNk67JHjlHC3Ctc5XTk-u8vMlZqvQUynYuPWtFzvq00nFhn0CVzliOc7RSNN2z0R_rhEzxsDbw9jREaZomAgHEQcvc70lAJep0wl6-bYcy5ouNecpYuBi3wiuzcH0LXYBscPQOILkV6qRU9kvm2ACEuow15xNzgTYPo38ixwEYwkSFmRC3QHr53skoxz_jSOjZyCdKj5qlD_HBCTheTi2cIGVuwKPVW91TVUPb1QxdR_nVDF1HF9YMfVaNd7jYj3-xCr1FauaoSqqEuIyzzKQ1JCUK0yKP0my0BssTVWzaywpkSq1cUZUpllgB9HWxv6Zl1FKW_KmkalKqJT9lnDalaa4VK0UzS6f6qmGypUmZ3ihNFaejNQcrJPLVQaUUVJr0XqW5n4vyyimoNBTTaVjfTF8KHxiaHmFUAT_4_y4_HgmQRxLkkQh5JEMKIPKI2N_BJPo_HZmEegyWKADlI-puVGLIU8ioeyAp44t0KaRqUKkENNVIVYyiKnApn1c6H4Wh-lCpz6tvA0mw9VEhR4Q_HPnDkbzY38CRe1xM7G8BEw2hbEY9gko0gHIZdVcqpeFT8j3qTlyisFOUM857E5ZS0CnLFee7BUxZ57Yo1_-OTxGbVhSWbORAcMDQyoPR0dg5p6Fms3lqvBrEfurOg6MDiRsYet6GtKJ7I9eCbvADWcE2vNVN_pX4JWzDEgWrL_SNhnEItp4v_uVtXVngGwffEbdBsMdhQdH8NijYHtYt09uRjuN8xG_Nve_9C03C1DeE8QFi0nji-3y_sRV7RsfuvPS6NjSF544ptG2zx3cFodvtGbBv2Q3HWEMHi9wT-RTwLvwEUQjS5p4GjdsrQCLf5jsdXmh3eny7LbS60HzpvcCeba-fbdjpcd023BnIaYVxWp6_afhiFHJ92GBy00E4wJebBsZo40IYFUwqDFDgQJHaSYSB65E3C-72XhD-Xt0koiPzZ3JStnUwIWZ-28aNaB5iNInfrDsQ3g>52929</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format is not idempotent - rerunning clang-format produces different answers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JohnC32
</td>
</tr>
</table>
<pre>
Rerunning clang-format 13 (and at least the last few prior versions) on already formatted code gives a different answer. Given
```c++
// <snip>
#define EML_CLONE_EXPRS(X) \
X(ASSIGN) \
X(VIRTUAL_ASSIGN) \
X(STRUCT_VALUE) \
X(ADD) X(MINUS) X(MUL) X(DIV) \
X(LT) X(LE) X(GT) X(GE) X(EQ) X(NE) \
X(CAND) X(COR) X(NOT) \
X(UMINUS) \
X(UPLUS) \
X(CALL) \
X(CHECK) \
X(VECTOR) \
X(MMUL) X(MDIV) X(MIDIV) X(MPOWER) \
X(IDIV) X(POWER) \
X(AND) X(OR) \
X(CTRANSPOSE) X(TRANSPOSE) \
X(VCAT) X(HCAT) \
X(VAR) X(CONST) X(DEREF) \
X(SUB) X(SUB_REF) \
X(FIELD) X(FIELD_REF) X(FIELDCOMP) \
X(EMPTY_MATRIX) \
X(ALL) X(ANY) \
X(END) X(SPAN) \
X(CELL_ARRAY) \
X(CELL_EMPTY) \
X(CELL_HCAT) \
X(CELL_VCAT) \
X(CELL_VAL) \
X(CELL_REF) \
X(CELL_TO_MATRIX) \
X(MATRIX) \
X(AT)
// <snip>
```
```bash
clang-format -i test.cpp > test1.cpp
clang-format -i test1.cpp > test2.cpp
clang-format -i test2.cpp > test3.cpp
.....
```
Then if you ```diff test1.cpp test2.cpp``` and ```diff test2.cpp test3.cpp``` you will see differences.
Here's the first clang-format result, test1.cpp:
```c++
// <snip>
#define EML_CLONE_EXPRS(X) \
X(ASSIGN) \
X(VIRTUAL_ASSIGN) \
X(STRUCT_VALUE) \
X(ADD) \
X(MINUS) X(MUL) X(DIV) X(LT) X(LE) X(GT) X(GE) X(EQ) X(NE) X(CAND) X(COR) \
X(NOT) X(UMINUS) X(UPLUS) X(CALL) X(CHECK) X(VECTOR) X(MMUL) X(MDIV) \
X(MIDIV) X(MPOWER) X(IDIV) X(POWER) X(AND) X(OR) X(CTRANSPOSE) \
X(TRANSPOSE) X(VCAT) X(HCAT) X(VAR) X(CONST) X(DEREF) X(SUB) \
X(SUB_REF) X(FIELD) X(FIELD_REF) X(FIELDCOMP) \
X(EMPTY_MATRIX) X(ALL) X(ANY) X(END) X(SPAN) \
X(CELL_ARRAY) X(CELL_EMPTY) X(CELL_HCAT) \
X(CELL_VCAT) X(CELL_VAL) X(CELL_REF) \
X(CELL_TO_MATRIX) X(MATRIX) X(AT)
// <snip>
```
Here's the second clang-format result, test2.cpp:
```c++
// <snip>
#define EML_CLONE_EXPRS(X) \
X(ASSIGN) \
X(VIRTUAL_ASSIGN) \
X(STRUCT_VALUE) \
X(ADD) \
X(MINUS) \
X(MUL) X(DIV) X(LT) X(LE) X(GT) X(GE) X(EQ) X(NE) X(CAND) X(COR) X(NOT) \
X(UMINUS) X(UPLUS) X(CALL) X(CHECK) X(VECTOR) X(MMUL) X(MDIV) X(MIDIV) \
X(MPOWER) X(IDIV) X(POWER) X(AND) X(OR) X(CTRANSPOSE) X(TRANSPOSE) \
X(VCAT) X(HCAT) X(VAR) X(CONST) X(DEREF) X(SUB) X(SUB_REF) \
X(FIELD) X(FIELD_REF) X(FIELDCOMP) X(EMPTY_MATRIX) X(ALL) \
X(ANY) X(END) X(SPAN) X(CELL_ARRAY) X(CELL_EMPTY) \
X(CELL_HCAT) X(CELL_VCAT) X(CELL_VAL) X(CELL_REF) \
X(CELL_TO_MATRIX) X(MATRIX) X(AT)
// <snip>
```
Here's the thrid clang-format result, test3.cpp:
```c++
// <snip>
#define EML_CLONE_EXPRS(X) \
X(ASSIGN) \
X(VIRTUAL_ASSIGN) \
X(STRUCT_VALUE) \
X(ADD) \
X(MINUS) \
X(MUL) \
X(DIV) X(LT) X(LE) X(GT) X(GE) X(EQ) X(NE) X(CAND) X(COR) X(NOT) X(UMINUS) \
X(UPLUS) X(CALL) X(CHECK) X(VECTOR) X(MMUL) X(MDIV) X(MIDIV) X(MPOWER) \
X(IDIV) X(POWER) X(AND) X(OR) X(CTRANSPOSE) X(TRANSPOSE) X(VCAT) \
X(HCAT) X(VAR) X(CONST) X(DEREF) X(SUB) X(SUB_REF) X(FIELD) \
X(FIELD_REF) X(FIELDCOMP) X(EMPTY_MATRIX) X(ALL) X(ANY) \
X(END) X(SPAN) X(CELL_ARRAY) X(CELL_EMPTY) \
X(CELL_HCAT) X(CELL_VCAT) X(CELL_VAL) X(CELL_REF) \
X(CELL_TO_MATRIX) X(MATRIX) X(AT)
// <snip>
```
Here the _clang-format file used:
```yaml
---
BasedOnStyle: Google
IndentWidth: 4
...
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztmduPqjgcx_8afGk0Cl7GBx4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