summaryrefslogtreecommitdiffstats
path: root/lib/Format/UnwrappedLineFormatter.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2018-09-13 07:27:15 +0000
committerOwen Pan <owenpiano@gmail.com>2018-09-13 07:27:15 +0000
commit903444bc95812173cc7ba92786b9b569e28984e9 (patch)
treec51fb8e1acef0e9fdd649e989aeba9d1dcaba913 /lib/Format/UnwrappedLineFormatter.cpp
parentca6d65812f8d6ba6093d0ea0d0bfd9cac518789d (diff)
[clang-format] Wrapped block after case label should not be merged into one line
PR38854 Differential Revision: http://reviews.llvm.org/D51719 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineFormatter.cpp')
-rw-r--r--lib/Format/UnwrappedLineFormatter.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Format/UnwrappedLineFormatter.cpp b/lib/Format/UnwrappedLineFormatter.cpp
index f0d93a1f4f..43d71504ca 100644
--- a/lib/Format/UnwrappedLineFormatter.cpp
+++ b/lib/Format/UnwrappedLineFormatter.cpp
@@ -323,6 +323,10 @@ private:
kwId == clang::tok::objc_synchronized)
return 0;
}
+ // Don't merge block with left brace wrapped after case labels
+ if (TheLine->First->is(tok::l_brace) && I != AnnotatedLines.begin() &&
+ I[-1]->First->isOneOf(tok::kw_case, tok::kw_default))
+ return 0;
// Try to merge a block with left brace wrapped that wasn't yet covered
if (TheLine->Last->is(tok::l_brace)) {
return !Style.BraceWrapping.AfterFunction ||