summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2017-06-19 07:40:49 +0000
committerDaniel Jasper <djasper@google.com>2017-06-19 07:40:49 +0000
commit6a7d5a7a22a6522e0bfb7e60b3a15acb2eed2f60 (patch)
treee31da3c516b5de6dabbba11f72a2b56b23beb387 /clang/lib/Format/ContinuationIndenter.cpp
parent271dd0603e4ddb63e1c7cc140459cb42fe13a2ac (diff)
downloadbcm5719-llvm-6a7d5a7a22a6522e0bfb7e60b3a15acb2eed2f60.tar.gz
bcm5719-llvm-6a7d5a7a22a6522e0bfb7e60b3a15acb2eed2f60.zip
clang-format: Handle "if constexpr".
c++1z adds the following constructions to the language: if constexpr (cond) statement1; else if constexpr (cond) statement2; else if constexpr (cond) statement3; else statement4; A first version of this was proposed in reviews.llvm.org/D26953 by Francis Visoiu Mistrih, but never commited. This patch additionally fixes the behavior when allowing short if statements on a single line and was authored by Jacob Bandes-Storch. Thank you to both authors. llvm-svn: 305666
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 387923031f8..bc8fe549954 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -453,7 +453,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
State.Column += Spaces;
if (Current.isNot(tok::comment) && Previous.is(tok::l_paren) &&
Previous.Previous &&
- Previous.Previous->isOneOf(tok::kw_if, tok::kw_for)) {
+ (Previous.Previous->isOneOf(tok::kw_if, tok::kw_for) ||
+ Previous.Previous->endsSequence(tok::kw_constexpr, tok::kw_if))) {
// Treat the condition inside an if as if it was a second function
// parameter, i.e. let nested calls have a continuation indent.
State.Stack.back().LastSpace = State.Column;
OpenPOWER on IntegriCloud