jacob-abraham updated this revision to Diff 466166.
jacob-abraham added a comment.

Fix patch, sorry about that


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

https://reviews.llvm.org/D135422

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/test/Format/macro.cpp


Index: clang/test/Format/macro.cpp
===================================================================
--- /dev/null
+++ clang/test/Format/macro.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-format -style="{AllowShortCaseLabelsOnASingleLine: true}" %s > %t
+// RUN: diff %s %t
+#define X                                                                      
\
+  case 0: break;
+#include "f"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -643,6 +643,7 @@
     unsigned Length = 0;
     bool EndsWithComment = false;
     bool InPPDirective = I[0]->InPPDirective;
+    bool InMacroBody = I[0]->InMacroBody;
     const unsigned Level = I[0]->Level;
     for (; NumStmts < 3; ++NumStmts) {
       if (I + 1 + NumStmts == E)
@@ -650,6 +651,8 @@
       const AnnotatedLine *Line = I[1 + NumStmts];
       if (Line->InPPDirective != InPPDirective)
         break;
+      if(Line->InMacroBody != InMacroBody)
+        break;
       if (Line->First->isOneOf(tok::kw_case, tok::kw_default, tok::r_brace))
         break;
       if (Line->First->isOneOf(tok::kw_if, tok::kw_for, tok::kw_switch,


Index: clang/test/Format/macro.cpp
===================================================================
--- /dev/null
+++ clang/test/Format/macro.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-format -style="{AllowShortCaseLabelsOnASingleLine: true}" %s > %t
+// RUN: diff %s %t
+#define X                                                                      \
+  case 0: break;
+#include "f"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -643,6 +643,7 @@
     unsigned Length = 0;
     bool EndsWithComment = false;
     bool InPPDirective = I[0]->InPPDirective;
+    bool InMacroBody = I[0]->InMacroBody;
     const unsigned Level = I[0]->Level;
     for (; NumStmts < 3; ++NumStmts) {
       if (I + 1 + NumStmts == E)
@@ -650,6 +651,8 @@
       const AnnotatedLine *Line = I[1 + NumStmts];
       if (Line->InPPDirective != InPPDirective)
         break;
+      if(Line->InMacroBody != InMacroBody)
+        break;
       if (Line->First->isOneOf(tok::kw_case, tok::kw_default, tok::r_brace))
         break;
       if (Line->First->isOneOf(tok::kw_if, tok::kw_for, tok::kw_switch,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to