[clang-format] Correct the AfterControlStatement configuration option output style
authormydeveloperday <mydeveloperday@gmail.com>
Thu, 30 Apr 2020 10:05:02 +0000 (11:05 +0100)
committermydeveloperday <mydeveloperday@gmail.com>
Thu, 30 Apr 2020 10:05:02 +0000 (11:05 +0100)
Summary:
Due to the order in which the enum cases were defined the old options which were retained for backwards compatibility were being preferred over the new options when printing with the --dump-config option.

Reviewers: MyDeveloperDay

Reviewed By: MyDeveloperDay

Patch By:  duncan-llvm

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79020

clang/lib/Format/Format.cpp

index 737e502..872f700 100644 (file)
@@ -195,11 +195,13 @@ struct ScalarEnumerationTraits<
   static void
   enumeration(IO &IO,
               FormatStyle::BraceWrappingAfterControlStatementStyle &Value) {
-    IO.enumCase(Value, "false", FormatStyle::BWACS_Never);
-    IO.enumCase(Value, "true", FormatStyle::BWACS_Always);
     IO.enumCase(Value, "Never", FormatStyle::BWACS_Never);
     IO.enumCase(Value, "MultiLine", FormatStyle::BWACS_MultiLine);
     IO.enumCase(Value, "Always", FormatStyle::BWACS_Always);
+
+    // For backward compatibility.
+    IO.enumCase(Value, "false", FormatStyle::BWACS_Never);
+    IO.enumCase(Value, "true", FormatStyle::BWACS_Always);
   }
 };