summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 872545660ca..2812a405b87 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -182,10 +182,6 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
State.Stack.back().ObjCSelectorNameFound &&
State.Stack.back().BreakBeforeParameter)
return true;
- if (Current.Type == TT_CtorInitializerColon &&
- (!Style.AllowShortFunctionsOnASingleLine ||
- Style.BreakConstructorInitializersBeforeComma || Style.ColumnLimit != 0))
- return true;
if (Previous.ClosesTemplateDeclaration && State.ParenLevel == 0 &&
!Current.isTrailingComment())
return true;
@@ -199,6 +195,18 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
(State.Stack.back().BreakBeforeParameter &&
State.Stack.back().ContainsUnwrappedBuilder)))
return true;
+
+ // The following could be precomputed as they do not depend on the state.
+ // However, as they should take effect only if the UnwrappedLine does not fit
+ // into the ColumnLimit, they are checked here in the ContinuationIndenter.
+ if (Previous.BlockKind == BK_Block && Previous.is(tok::l_brace) &&
+ !Current.isOneOf(tok::r_brace, tok::comment))
+ return true;
+ if (Current.Type == TT_CtorInitializerColon &&
+ (!Style.AllowShortFunctionsOnASingleLine ||
+ Style.BreakConstructorInitializersBeforeComma || Style.ColumnLimit != 0))
+ return true;
+
return false;
}
OpenPOWER on IntegriCloud