diff options
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 25 | 
1 files changed, 15 insertions, 10 deletions
| diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 021d8c6..8e227da 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -4427,10 +4427,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,    if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)      return Style.PenaltyBreakOpenParenthesis; -  if (Left.is(tok::l_paren) && InFunctionDecl && -      Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) { +  if (Left.is(tok::l_paren) && InFunctionDecl && Style.AlignAfterOpenBracket)      return 100; -  }    if (Left.is(tok::l_paren) && Left.Previous &&        (Left.Previous->isOneOf(tok::kw_for, tok::kw__Generic) ||         Left.Previous->isIf())) { @@ -4446,7 +4444,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,      // If we aren't aligning after opening parens/braces we can always break      // here unless the style does not want us to place all arguments on the      // next line. -    if (Style.AlignAfterOpenBracket == FormatStyle::BAS_DontAlign && +    if (!Style.AlignAfterOpenBracket &&          (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {        return 0;      } @@ -6226,24 +6224,31 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,                                     (Right.isBlockIndentedInitRBrace(Style)));    } -  // We only break before r_paren if we're in a block indented context. +  // We can break before r_paren if we're in a block indented context or +  // a control statement with an explicit style option.    if (Right.is(tok::r_paren)) { -    if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent || -        !Right.MatchingParen) { +    if (!Right.MatchingParen)        return false; -    }      auto Next = Right.Next;      if (Next && Next->is(tok::r_paren))        Next = Next->Next;      if (Next && Next->is(tok::l_paren))        return false;      const FormatToken *Previous = Right.MatchingParen->Previous; -    return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf())); +    if (!Previous) +      return false; +    if (Previous->isIf()) +      return Style.BreakBeforeCloseBracketIf; +    if (Previous->isLoop(Style)) +      return Style.BreakBeforeCloseBracketLoop; +    if (Previous->is(tok::kw_switch)) +      return Style.BreakBeforeCloseBracketSwitch; +    return Style.BreakBeforeCloseBracketFunction;    }    if (Left.isOneOf(tok::r_paren, TT_TrailingAnnotation) &&        Right.is(TT_TrailingAnnotation) && -      Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) { +      Style.BreakBeforeCloseBracketFunction) {      return false;    } | 
