From 9e5ede0f8b51c695eb734d388bc21333d310186d Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 8 Nov 2013 19:56:28 +0000 Subject: clang-format: Improve formatting of operators forced to new lines. Before: unsigned ContentSize = sizeof(int16_t) // DWARF ARange version number + sizeof(int32_t) // Offset of CU in the .debug_info section + sizeof(int8_t) // Pointer Size (in bytes) + sizeof(int8_t); // Segment Size (in bytes) After: unsigned ContentSize = sizeof(int16_t) // DWARF ARange version number + sizeof(int32_t) // Offset of CU in the .debug_info section + sizeof(int8_t) // Pointer Size (in bytes) + sizeof(int8_t); // Segment Size (in bytes) This fixes llvm.org/PR17687. llvm-svn: 194276 --- clang/lib/Format/ContinuationIndenter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'clang/lib/Format/ContinuationIndenter.cpp') diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 63232beb9f0..1f6c8693d68 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -439,10 +439,12 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) { State.Stack[i].BreakBeforeParameter = true; } - const FormatToken *TokenBefore = Current.getPreviousNonComment(); - if (TokenBefore && !TokenBefore->isOneOf(tok::comma, tok::semi) && - TokenBefore->Type != TT_TemplateCloser && - TokenBefore->Type != TT_BinaryOperator && !TokenBefore->opensScope()) + if (PreviousNonComment && + !PreviousNonComment->isOneOf(tok::comma, tok::semi) && + PreviousNonComment->Type != TT_TemplateCloser && + PreviousNonComment->Type != TT_BinaryOperator && + Current.Type != TT_BinaryOperator && + !PreviousNonComment->opensScope()) State.Stack.back().BreakBeforeParameter = true; // If we break after { or the [ of an array initializer, we should also break -- cgit v1.2.3