Skip to content

clang-format 7 and later cannot read RawStringFormats from 6.0 #44682

@Rondom

Description

@Rondom
mannequin
Bugzilla Link 45337
Version trunk
OS Linux
Attachments clang-format-file that works fine with 6.0 but not with later versions

Extended Description

Between clang-format 6.0 and 7.0, the format of the RawStringFormats property has changed. Instead of taking a string of one delimiter per list item (key "Delimiter") it takes multiple delimiters as a list (key "Delimiters") per list item in later versions of clang-format.

My expectation is that later versions of clang-format can process a .clang-format file produced with an earlier version of clang-format using the --dump-config switch without any manual changes.

https://releases.llvm.org/6.0.0/tools/clang/docs/ClangFormatStyleOptions.html#configurable-format-style-options
https://releases.llvm.org/7.0.0/tools/clang/docs/ClangFormatStyleOptions.html#configurable-format-style-options

To reproduce:

  1. Either
    a. Produce a .clang-format file using clang-format-6.0 --dump-config
    b. Create a .clang-format file with the following content (also attached)

Language: Cpp
RawStringFormats:

  • Delimiter: pb
    Language: TextProto
    BasedOnStyle: google
    ...
  1. Run latest clang-format on some file, e.g. clang-format -i main.cpp

Actual behaviour:

~/clang-format-test
❯ clang-format-6.0 -i main.cpp

~/clang-format-test
❯ clang-format-10 -i main.cpp

YAML:4:16: error: unknown key 'Delimiter'

  • Delimiter: pb
    ^~
    Error reading /home/tobii.intra/ag3512/clang-format-test/.clang-format: Invalid argument

~/clang-format-test

Expected behaviour:

The latest versionof clang-format should be able to format files just fine using the old .clang-format file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions