[llvm-bugs] [Bug 45337] New: clang-format 7 and later cannot read RawStringFormats from 6.0

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 28 10:22:53 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45337

            Bug ID: 45337
           Summary: clang-format 7 and later cannot read RawStringFormats
                    from 6.0
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rondom at rondom.de
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 23282
  --> https://bugs.llvm.org/attachment.cgi?id=23282&action=edit
clang-format-file that works fine with 6.0 but not with later versions

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

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200328/51a24995/attachment-0001.html>


More information about the llvm-bugs mailing list