asmith created this revision.
asmith added reviewers: jbcoe, MyDeveloperDay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
asmith added a reviewer: thakis.

Before this change enums were formatted incorrectly for the Microsoft style.

      

[Original Source]

  
  enum {
    one,
    two
  } three, four;


[Incorrectly Formatted]

  
  enum blah
  {
    one,
    two
  } three,
      four;


[Correct Format with Patch]

  
  enum blah
  {
    one,
    two
  } three, four;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78982

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2280,9 +2280,18 @@
     return true;
   }
 
+  if (Style.BraceWrapping.AfterEnum)
+    addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (Style.BraceWrapping.AfterEnum) {
+    addUnwrappedLine();
+    Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (Style.BraceWrapping.AfterEnum)
+    Line->Level -= 1;
+  
   if (HasError) {
     if (FormatTok->is(tok::semi))
       nextToken();


Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2280,9 +2280,18 @@
     return true;
   }
 
+  if (Style.BraceWrapping.AfterEnum)
+    addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (Style.BraceWrapping.AfterEnum) {
+    addUnwrappedLine();
+    Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (Style.BraceWrapping.AfterEnum)
+    Line->Level -= 1;
+  
   if (HasError) {
     if (FormatTok->is(tok::semi))
       nextToken();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to