[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141654#4053470 , @rymiel wrote:

> This also made me wonder, is there an actual policy on deprecated options? As 
> in, when they are actually removed.

We deprecate options only as a cleanup (as in this patch) or when adding new 
options (as in D108752 ) and should keep 
maintain backward compatibility. (Also see the original idea from 
@MyDeveloperDay in https://reviews.llvm.org/D19031#1745767.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141654#4053551 , 
@HazardyKnusperkeks wrote:

> In D141654#4053470 , @rymiel wrote:
>
>> This also made me wonder, is there an actual policy on deprecated options? 
>> As in, when they are actually removed. Is there even prior precedent for 
>> doing this? (I wouldn't know because I'm a very recent user)
>
> I think the first one was D108752  and the 
> documentation can handle that since D127578 
> .
> Removing an option is not different than changing the type of an option, 
> users of `libformat` have to adapt, and users of `clang-format` don't notice 
> (if everything is done right), because the parsing for the removed options is 
> still there, see lines 1068 and following of `Format.cpp` in this change.

+1.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D141654#4053470 , @rymiel wrote:

> This also made me wonder, is there an actual policy on deprecated options? As 
> in, when they are actually removed. Is there even prior precedent for doing 
> this? (I wouldn't know because I'm a very recent user)

I think the first one was D108752  and the 
documentation can handle that since D127578 .
Removing an option is not different than changing the type of an option, users 
of `libformat` have to adapt, and users of `clang-format` don't notice (if 
everything is done right), because the parsing for the removed options is still 
there, see lines 1068 and following of `Format.cpp` in this change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

This also made me wonder, is there an actual policy on deprecated options? As 
in, when they are actually removed. Is there even prior precedent for doing 
this? (I wouldn't know because I'm a very recent user)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe3eca3359402: [clang-format] Replace DeriveLineEnding and 
UseCRLF with LineEnding (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22218,8 +22218,7 @@
 
   FormatStyle style = getLLVMStyle();
 
-  style.DeriveLineEnding = true;
-  style.UseCRLF = false;
+  EXPECT_EQ(style.LineEnding, FormatStyle::LE_DeriveLF);
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
@@ -22231,7 +22230,7 @@
"  int baz;\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_DeriveCRLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22244,8 +22243,7 @@
"};",
style));
 
-  style.DeriveLineEnding = false;
-  style.UseCRLF = false;
+  style.LineEnding = FormatStyle::LE_LF;
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
@@ -22259,7 +22257,7 @@
"  int qux;\r\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_CRLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22274,8 +22272,7 @@
"};",
style));
 
-  style.DeriveLineEnding = true;
-  style.UseCRLF = false;
+  style.LineEnding = FormatStyle::LE_DeriveLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22289,7 +22286,7 @@
"  int qux;\r\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_DeriveCRLF;
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -155,7 +155,6 @@
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
-  CHECK_PARSE_BOOL(DeriveLineEnding);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
@@ -193,7 +192,6 @@
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
   CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
-  CHECK_PARSE_BOOL(UseCRLF);
 
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
@@ -886,6 +884,20 @@
   FormatStyle::ABS_Leave);
   CHECK_PARSE("BreakAfterAttributes: Never", BreakAfterAttributes,
   FormatStyle::ABS_Never);
+
+  const auto DefaultLineEnding = FormatStyle::LE_DeriveLF;
+  CHECK_PARSE("LineEnding: LF", LineEnding, FormatStyle::LE_LF);
+  CHECK_PARSE("LineEnding: CRLF", LineEnding, FormatStyle::LE_CRLF);
+  CHECK_PARSE("LineEnding: DeriveCRLF", LineEnding, FormatStyle::LE_DeriveCRLF);
+  CHECK_PARSE("LineEnding: DeriveLF", LineEnding, DefaultLineEnding);
+  // For backward compatibility:
+  CHECK_PARSE("DeriveLineEnding: false", LineEnding, FormatStyle::LE_LF);
+  Style.LineEnding = DefaultLineEnding;
+  CHECK_PARSE("DeriveLineEnding: false\n"
+  "UseCRLF: true",
+  LineEnding, FormatStyle::LE_CRLF);
+  Style.LineEnding = DefaultLineEnding;
+  CHECK_PARSE("UseCRLF: true", LineEnding, FormatStyle::LE_DeriveCRLF);
 }
 
 TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -403,6 +403,15 @@
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO , FormatStyle::LineEndingStyle ) {
+IO.enumCase(Value, "LF", FormatStyle::LE_LF);
+IO.enumCase(Value, "CRLF", FormatStyle::LE_CRLF);
+IO.enumCase(Value, "DeriveLF", FormatStyle::LE_DeriveLF);
+IO.enumCase(Value, "DeriveCRLF", FormatStyle::LE_DeriveCRLF);
+  }
+};
+
 template 

[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141654#4050852 , @rymiel wrote:

> I'm not sure what the strict //benefit// of squishing the two options 
> together is, but I support it

See D108752  and the added table in the 
summary.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141654#4052510 , 
@HazardyKnusperkeks wrote:

> In D141654#4050852 , @rymiel wrote:
>
>> (This needs to run the updated dump script from D138446 
>> )
>>
>> I'm not sure what the strict //benefit// of squishing the two options 
>> together is, but I support it
>
> Having just one option instead of two, for one feature is better, especially 
> when the two options are that far apart in the documentation.

+1.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 489125.
owenpan added a comment.

Rebased and ran the latest `dump_format_style.py` to generate 
`ClangFormatStyleOptions.rst`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22218,8 +22218,7 @@
 
   FormatStyle style = getLLVMStyle();
 
-  style.DeriveLineEnding = true;
-  style.UseCRLF = false;
+  EXPECT_EQ(style.LineEnding, FormatStyle::LE_DeriveLF);
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
@@ -22231,7 +22230,7 @@
"  int baz;\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_DeriveCRLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22244,8 +22243,7 @@
"};",
style));
 
-  style.DeriveLineEnding = false;
-  style.UseCRLF = false;
+  style.LineEnding = FormatStyle::LE_LF;
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
@@ -22259,7 +22257,7 @@
"  int qux;\r\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_CRLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22274,8 +22272,7 @@
"};",
style));
 
-  style.DeriveLineEnding = true;
-  style.UseCRLF = false;
+  style.LineEnding = FormatStyle::LE_DeriveLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22289,7 +22286,7 @@
"  int qux;\r\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_DeriveCRLF;
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -155,7 +155,6 @@
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
-  CHECK_PARSE_BOOL(DeriveLineEnding);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
@@ -193,7 +192,6 @@
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
   CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
-  CHECK_PARSE_BOOL(UseCRLF);
 
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
@@ -886,6 +884,20 @@
   FormatStyle::ABS_Leave);
   CHECK_PARSE("BreakAfterAttributes: Never", BreakAfterAttributes,
   FormatStyle::ABS_Never);
+
+  const auto DefaultLineEnding = FormatStyle::LE_DeriveLF;
+  CHECK_PARSE("LineEnding: LF", LineEnding, FormatStyle::LE_LF);
+  CHECK_PARSE("LineEnding: CRLF", LineEnding, FormatStyle::LE_CRLF);
+  CHECK_PARSE("LineEnding: DeriveCRLF", LineEnding, FormatStyle::LE_DeriveCRLF);
+  CHECK_PARSE("LineEnding: DeriveLF", LineEnding, DefaultLineEnding);
+  // For backward compatibility:
+  CHECK_PARSE("DeriveLineEnding: false", LineEnding, FormatStyle::LE_LF);
+  Style.LineEnding = DefaultLineEnding;
+  CHECK_PARSE("DeriveLineEnding: false\n"
+  "UseCRLF: true",
+  LineEnding, FormatStyle::LE_CRLF);
+  Style.LineEnding = DefaultLineEnding;
+  CHECK_PARSE("UseCRLF: true", LineEnding, FormatStyle::LE_DeriveCRLF);
 }
 
 TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -403,6 +403,15 @@
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO , FormatStyle::LineEndingStyle ) {
+IO.enumCase(Value, "LF", FormatStyle::LE_LF);
+IO.enumCase(Value, "CRLF", FormatStyle::LE_CRLF);
+IO.enumCase(Value, "DeriveLF", FormatStyle::LE_DeriveLF);
+IO.enumCase(Value, "DeriveCRLF", FormatStyle::LE_DeriveCRLF);
+  }
+};
+
 template <>
 struct ScalarEnumerationTraits {
   static void enumeration(IO ,
@@ -784,6 +793,9 @@
 bool BreakBeforeInheritanceComma = 

[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

In D141654#4050852 , @rymiel wrote:

> (This needs to run the updated dump script from D138446 
> )
>
> I'm not sure what the strict //benefit// of squishing the two options 
> together is, but I support it

Having just one option instead of two, for one feature is better, especially 
when the two options are that far apart in the documentation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel accepted this revision.
rymiel added a comment.
This revision is now accepted and ready to land.

(This needs to run the updated dump script from D138446 
)

I'm not sure what the strict //benefit// of squishing the two options together 
is, but I support it


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141654/new/

https://reviews.llvm.org/D141654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141654

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22175,8 +22175,7 @@
 
   FormatStyle style = getLLVMStyle();
 
-  style.DeriveLineEnding = true;
-  style.UseCRLF = false;
+  EXPECT_EQ(style.LineEnding, FormatStyle::LE_DeriveLF);
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
@@ -22188,7 +22187,7 @@
"  int baz;\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_DeriveCRLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22201,8 +22200,7 @@
"};",
style));
 
-  style.DeriveLineEnding = false;
-  style.UseCRLF = false;
+  style.LineEnding = FormatStyle::LE_LF;
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
@@ -22216,7 +22214,7 @@
"  int qux;\r\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_CRLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22231,8 +9,7 @@
"};",
style));
 
-  style.DeriveLineEnding = true;
-  style.UseCRLF = false;
+  style.LineEnding = FormatStyle::LE_DeriveLF;
   EXPECT_EQ("union FooBarBazQux {\r\n"
 "  int foo;\r\n"
 "  int bar;\r\n"
@@ -22246,7 +22243,7 @@
"  int qux;\r\n"
"};",
style));
-  style.UseCRLF = true;
+  style.LineEnding = FormatStyle::LE_DeriveCRLF;
   EXPECT_EQ("union FooBarBazQux {\n"
 "  int foo;\n"
 "  int bar;\n"
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -155,7 +155,6 @@
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
-  CHECK_PARSE_BOOL(DeriveLineEnding);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
@@ -193,7 +192,6 @@
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
   CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
-  CHECK_PARSE_BOOL(UseCRLF);
 
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
@@ -886,6 +884,20 @@
   FormatStyle::ABS_Leave);
   CHECK_PARSE("BreakAfterAttributes: Never", BreakAfterAttributes,
   FormatStyle::ABS_Never);
+
+  const auto DefaultLineEnding = FormatStyle::LE_DeriveLF;
+  CHECK_PARSE("LineEnding: LF", LineEnding, FormatStyle::LE_LF);
+  CHECK_PARSE("LineEnding: CRLF", LineEnding, FormatStyle::LE_CRLF);
+  CHECK_PARSE("LineEnding: DeriveCRLF", LineEnding, FormatStyle::LE_DeriveCRLF);
+  CHECK_PARSE("LineEnding: DeriveLF", LineEnding, DefaultLineEnding);
+  // For backward compatibility:
+  CHECK_PARSE("DeriveLineEnding: false", LineEnding, FormatStyle::LE_LF);
+  Style.LineEnding = DefaultLineEnding;
+  CHECK_PARSE("DeriveLineEnding: false\n"
+  "UseCRLF: true",
+  LineEnding, FormatStyle::LE_CRLF);
+  Style.LineEnding = DefaultLineEnding;
+  CHECK_PARSE("UseCRLF: true", LineEnding, FormatStyle::LE_DeriveCRLF);
 }
 
 TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -403,6 +403,15 @@
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO , FormatStyle::LineEndingStyle ) {
+IO.enumCase(Value, "LF", FormatStyle::LE_LF);
+IO.enumCase(Value, "CRLF", FormatStyle::LE_CRLF);
+IO.enumCase(Value, "DeriveLF", FormatStyle::LE_DeriveLF);
+IO.enumCase(Value, "DeriveCRLF", FormatStyle::LE_DeriveCRLF);
+  }
+};
+
 template <>
 struct ScalarEnumerationTraits {