Issue 134395
Summary [clang-format] Filter options dumped by `-dump-config`
Labels clang-format
Assignees
Reporter SunBlack
    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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to