<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134395>134395</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] Filter options dumped by `-dump-config`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
SunBlack
</td>
</tr>
</table>
<pre>
When we switch to a new version of Clang format, I currently always use `-dump-config > .clang-format_new` in the folder where our currently used config file is located and then do a diff on the files to see what has changed since the last update, so I don't have to go through the changelogs of different versions (and the missing entries in them like the new TableGen options in the changelog of CF 19).
Clang-Format currently dumps all options, even if they are not relevant. For example, there are Java entries in the C++ block, which is currently not so easy to recognize (see also #134390).
So the dumped file looks, e.g., like:
```yml
---
Language: Cpp
# ...
AllowShortCaseExpressionOnASingleLine: true
# ...
...
```
As the yml files supports [multiple languages](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#configuring-style-with-clang-format) within a single config file, I would expect sth. like this:
```yml
---
Language: Cpp
# ...
---
Language: Java
AllowShortCaseExpressionOnASingleLine: true
# ...
...
```
So I suggest improving `-dump-config` by following things:
1) In case `LanguageKind` is `None` it could still print all options within this block
2) If a specific language (or multiple) is configured, only output options for this language (filtering) within the block.
3) In case there is a `None`-Language-Block and a (or multiple) specific blocks: In case an option is just for a specific language, add the option just in this block, otherwise in the general block.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU2P2zYQ_TX0ZSBBpqxd--CDdxMXaYPm4AI9FjQ1kpilSIFDWXF_fTGU7HjTHHroYrHGWvP13ps3UkSmdYh7Ub2I6sNKjbHzYX8a3YtV-m119vV1_2eHDiYEmkzUHUQPChxOcMFAxjvwDbxa5VpofOhVFPIVPoEeQ0AX7RWUndSVYCQE8VRk9dgPmfauMS2I8iPkmnOzOfcvh5N4KsA4iB1C422NAaYOA4Ifw0PVkbCGpUxjLIIhsF6riDU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