Skip to content

[clang-format] Filter options dumped by -dump-config #134395

Open
@SunBlack

Description

@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:

---
Language:        Cpp
# ...
AllowShortCaseExpressionOnASingleLine: true
# ...
...

As the yml files supports multiple languages within a single config file, I would expect sth. like this:

---
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions