<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/78067>78067</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] Add `Leave` option for `AlwaysBreakTemplateDeclarations`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pokanoka
</td>
</tr>
</table>
<pre>
Currently `AlwaysBreakTemplateDeclarations` (`BreakTemplateDeclarationsStyle`) has 3 possible options: Yes, No, and MultiLine.
However, for some projects it's not enough due to the sheer volume of possibilities. The fact that there can also be attributes, requires clauses, and compiler-specific stuff like __declspec doesn't make it any easier.
Since it seems quite hard (and out of scope) to cover all possibilities, it would be nice if there was just one additional option **`Leave`**, to keep existing template break formatting as is.
### Example
Base config:
```
BasedOnStyle: LLVM
RequiresClausePosition: WithPreceding
IndentRequiresClause: false
PenaltyBreakTemplateDeclaration: 0
```
#### AlwaysBreakTemplateDeclarations: Yes
```
template <auto x>
constexpr int simple(int) {
char c;
return 1;
}
template <auto x>
requires(x > 1)
constexpr int with_req(int) {
char c;
return 1;
}
```
#### AlwaysBreakTemplateDeclarations: No
For this example it's same as `MultiLine`.
```
template <auto x> constexpr int simple(int) {
char c;
return 1;
}
template <auto x> requires(x > 1)
constexpr int with_req(int) {
char c;
return 1;
}
```
#### AlwaysBreakTemplateDeclarations: **Leave**
With this proposed option clang-format is supposed to neither remove a break nor insert it. The `RequiresClausePosition` still ought to be respected.
```
template <auto x>
constexpr int simple(int) {
char c;
return 1;
}
template <auto x> requires(x > 1)
constexpr int with_req(int) {
char c;
return 1;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVlFv4zYM_jXKC9FAllM7echD2l6wAb1bsTts2FMhy3Ssiyy5Ip02_35Q7Hbt0N56wG7AAEEGRIrip4_6TE1kdx5xLc4vxPnVTA_chrjuw177sNezKt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