summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-23 21:45:03 +0000
committerDaniel Jasper <djasper@google.com>2014-11-23 21:45:03 +0000
commit79f226e780449291f5905fac05c0ae864068a28d (patch)
treeb116fb5f8e3f31bd2994d9e8133731eaf24ed818 /clang/lib/Format
parent325e486f9b249a2ff645afb8a4cb7caa36fcd239 (diff)
downloadbcm5719-llvm-79f226e780449291f5905fac05c0ae864068a28d.tar.gz
bcm5719-llvm-79f226e780449291f5905fac05c0ae864068a28d.zip
clang-format: Make short case labels work with #ifs
Before: switch (a) { #if FOO case 0: return 0; #endif } After: switch (a) { #if FOO case 0: return 0; #endif } This fixed llvm.org/PR21544. llvm-svn: 222642
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/Format.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 6518b246a88..8a04571a8cb 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -742,10 +742,13 @@ private:
return 0;
unsigned NumStmts = 0;
unsigned Length = 0;
+ bool InPPDirective = I[0]->InPPDirective;
for (; NumStmts < 3; ++NumStmts) {
if (I + 1 + NumStmts == E)
break;
const AnnotatedLine *Line = I[1 + NumStmts];
+ if (Line->InPPDirective != InPPDirective)
+ 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,
OpenPOWER on IntegriCloud