From 70f886033a4637e1fb6e4b8ab1fad09a3dcca5a7 Mon Sep 17 00:00:00 2001 From: Paul Hoad Date: Fri, 1 Mar 2019 09:09:54 +0000 Subject: [clang-format] [NFC] clang-format the Format library Previously revisions commited non-clang-formatted changes to the Format library, this means submitting any revision e.g. {D55170} can cause additional whitespace changes to potentially be included in a revision. Commit a non functional change using latest build Windows clang-format r351376 with no other changes, to remove these differences All FormatTests pass [==========] 652 tests from 20 test cases ran. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355182 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/BreakableToken.cpp | 19 +++++------- lib/Format/BreakableToken.h | 8 ++--- lib/Format/ContinuationIndenter.cpp | 28 +++++++++--------- lib/Format/Format.cpp | 39 ++++++++++--------------- lib/Format/FormatToken.h | 3 +- lib/Format/FormatTokenLexer.h | 2 +- lib/Format/TokenAnnotator.cpp | 28 +++++++++--------- lib/Format/UnwrappedLineFormatter.cpp | 19 +++++------- lib/Format/UnwrappedLineFormatter.h | 6 ++-- lib/Format/UnwrappedLineParser.cpp | 9 +++--- lib/Format/UnwrappedLineParser.h | 3 +- lib/Format/WhitespaceManager.cpp | 55 ++++++++++++++++++----------------- 12 files changed, 96 insertions(+), 123 deletions(-) diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index c74965a972..ec197aa541 100644 --- a/lib/Format/BreakableToken.cpp +++ b/lib/Format/BreakableToken.cpp @@ -62,12 +62,10 @@ static StringRef getLineCommentIndentPrefix(StringRef Comment, return LongestPrefix; } -static BreakableToken::Split getCommentSplit(StringRef Text, - unsigned ContentStartColumn, - unsigned ColumnLimit, - unsigned TabWidth, - encoding::Encoding Encoding, - const FormatStyle &Style) { +static BreakableToken::Split +getCommentSplit(StringRef Text, unsigned ContentStartColumn, + unsigned ColumnLimit, unsigned TabWidth, + encoding::Encoding Encoding, const FormatStyle &Style) { LLVM_DEBUG(llvm::dbgs() << "Comment split: \"" << Text << "\", Column limit: " << ColumnLimit << ", Content start: " << ContentStartColumn << "\n"); @@ -191,7 +189,7 @@ bool switchesFormatting(const FormatToken &Token) { unsigned BreakableToken::getLengthAfterCompression(unsigned RemainingTokenColumns, - Split Split) const { + Split Split) const { // Example: consider the content // lala lala // - RemainingTokenColumns is the original number of columns, 10; @@ -870,23 +868,20 @@ void BreakableLineCommentSection::reflow(unsigned LineIndex, // the next line. unsigned WhitespaceLength = Lines[LineIndex].data() - tokenAt(LineIndex).TokenText.data() - Offset; - Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], - Offset, + Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], Offset, /*ReplaceChars=*/WhitespaceLength, /*PreviousPostfix=*/"", /*CurrentPrefix=*/"", /*InPPDirective=*/false, /*Newlines=*/0, /*Spaces=*/0); - } // Replace the indent and prefix of the token with the reflow prefix. unsigned Offset = Lines[LineIndex].data() - tokenAt(LineIndex).TokenText.data(); unsigned WhitespaceLength = Content[LineIndex].data() - Lines[LineIndex].data(); - Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], - Offset, + Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], Offset, /*ReplaceChars=*/WhitespaceLength, /*PreviousPostfix=*/"", /*CurrentPrefix=*/ReflowPrefix, diff --git a/lib/Format/BreakableToken.h b/lib/Format/BreakableToken.h index 86cb4b71e7..5fab3f2f11 100644 --- a/lib/Format/BreakableToken.h +++ b/lib/Format/BreakableToken.h @@ -146,9 +146,7 @@ public: // * @param loooooooooooooong line // * continuation // */ - virtual unsigned getContentIndent(unsigned LineIndex) const { - return 0; - } + virtual unsigned getContentIndent(unsigned LineIndex) const { return 0; } /// Returns a range (offset, length) at which to break the line at /// \p LineIndex, if previously broken at \p TailOffset. If possible, do not @@ -202,9 +200,7 @@ public: /// Returns whether there will be a line break at the start of the /// token. - virtual bool introducesBreakBeforeToken() const { - return false; - } + virtual bool introducesBreakBeforeToken() const { return false; } /// Replaces the whitespace between \p LineIndex-1 and \p LineIndex. virtual void adaptStartOfLine(unsigned LineIndex, diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index cfa7dc7cf8..a82c8ce5b5 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -403,8 +403,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { // FIXME: We should find a more generic solution to this problem. !(State.Column <= NewLineColumn && Style.Language == FormatStyle::LK_JavaScript) && - !(Previous.closesScopeAfterBlock() && - State.Column <= NewLineColumn)) + !(Previous.closesScopeAfterBlock() && State.Column <= NewLineColumn)) return true; // If the template declaration spans multiple lines, force wrap before the @@ -835,8 +834,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, // about removing empty lines on closing blocks. Special case them here. MaxEmptyLinesToKeep = 1; } - unsigned Newlines = std::max( - 1u, std::min(Current.NewlinesBefore, MaxEmptyLinesToKeep)); + unsigned Newlines = + std::max(1u, std::min(Current.NewlinesBefore, MaxEmptyLinesToKeep)); bool ContinuePPDirective = State.Line->InPPDirective && State.Line->Type != LT_ImportStatement; Whitespaces.replaceWhitespace(Current, Newlines, State.Column, State.Column, @@ -1168,8 +1167,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, State.Column += Current.ColumnWidth; State.NextToken = State.NextToken->Next; - unsigned Penalty = - handleEndOfLine(Current, State, DryRun, AllowBreak); + unsigned Penalty = handleEndOfLine(Current, State, DryRun, AllowBreak); if (Current.Role) Current.Role->formatFromToken(State, this, DryRun); @@ -1530,9 +1528,8 @@ unsigned ContinuationIndenter::reformatRawStringLiteral( // that raw string prefix starts, and // - if the raw string prefix does not start on a newline, it is the current // indent. - unsigned LastStartColumn = Current.NewlinesBefore - ? FirstStartColumn - NewPrefixSize - : CurrentIndent; + unsigned LastStartColumn = + Current.NewlinesBefore ? FirstStartColumn - NewPrefixSize : CurrentIndent; std::pair Fixes = internal::reformat( RawStringStyle, RawText, {tooling::Range(0, RawText.size())}, @@ -1589,8 +1586,9 @@ unsigned ContinuationIndenter::reformatRawStringLiteral( // have to manually add the penalty for the prefix R"delim( over the column // limit. unsigned PrefixExcessCharacters = - StartColumn + NewPrefixSize > Style.ColumnLimit ? - StartColumn + NewPrefixSize - Style.ColumnLimit : 0; + StartColumn + NewPrefixSize > Style.ColumnLimit + ? StartColumn + NewPrefixSize - Style.ColumnLimit + : 0; bool IsMultiline = ContentStartsOnNewline || (NewCode->find('\n') != std::string::npos); if (IsMultiline) { @@ -1708,16 +1706,16 @@ ContinuationIndenter::getRawStringStyle(const FormatToken &Current, return RawStringStyle; } -std::unique_ptr ContinuationIndenter::createBreakableToken( - const FormatToken &Current, LineState &State, bool AllowBreak) { +std::unique_ptr +ContinuationIndenter::createBreakableToken(const FormatToken &Current, + LineState &State, bool AllowBreak) { unsigned StartColumn = State.Column - Current.ColumnWidth; if (Current.isStringLiteral()) { // FIXME: String literal breaking is currently disabled for Java and JS, as // it requires strings to be merged using "+" which we don't support. if (Style.Language == FormatStyle::LK_Java || Style.Language == FormatStyle::LK_JavaScript || - !Style.BreakStringLiterals || - !AllowBreak) + !Style.BreakStringLiterals || !AllowBreak) return nullptr; // Don't break string literals inside preprocessor directives (except for diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 1827c4a8b1..a5023ec301 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -149,8 +149,8 @@ struct ScalarEnumerationTraits { template <> struct ScalarEnumerationTraits { - static void - enumeration(IO &IO, FormatStyle::BreakInheritanceListStyle &Value) { + static void enumeration(IO &IO, + FormatStyle::BreakInheritanceListStyle &Value) { IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon); IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma); IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon); @@ -179,7 +179,8 @@ struct ScalarEnumerationTraits { template <> struct ScalarEnumerationTraits { - static void enumeration(IO &IO, FormatStyle::BreakTemplateDeclarationsStyle &Value) { + static void enumeration(IO &IO, + FormatStyle::BreakTemplateDeclarationsStyle &Value) { IO.enumCase(Value, "No", FormatStyle::BTDS_No); IO.enumCase(Value, "MultiLine", FormatStyle::BTDS_MultiLine); IO.enumCase(Value, "Yes", FormatStyle::BTDS_Yes); @@ -361,10 +362,8 @@ template <> struct MappingTraits { IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces); bool BreakBeforeInheritanceComma = false; - IO.mapOptional("BreakBeforeInheritanceComma", - BreakBeforeInheritanceComma); - IO.mapOptional("BreakInheritanceList", - Style.BreakInheritanceList); + IO.mapOptional("BreakBeforeInheritanceComma", BreakBeforeInheritanceComma); + IO.mapOptional("BreakInheritanceList", Style.BreakInheritanceList); // If BreakBeforeInheritanceComma was specified but // BreakInheritance was not, initialize the latter from the // former for backwards compatibility. @@ -854,15 +853,9 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) { // See styleguide for import groups: // https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order ChromiumStyle.JavaImportGroups = { - "android", - "com", - "dalvik", - "junit", - "org", - "com.google.android.apps.chrome", - "org.chromium", - "java", - "javax", + "android", "com", "dalvik", + "junit", "org", "com.google.android.apps.chrome", + "org.chromium", "java", "javax", }; ChromiumStyle.SortIncludes = true; } else if (Language == FormatStyle::LK_JavaScript) { @@ -1063,9 +1056,7 @@ void FormatStyle::FormatStyleSet::Add(FormatStyle Style) { (*Styles)[Style.Language] = std::move(Style); } -void FormatStyle::FormatStyleSet::Clear() { - Styles.reset(); -} +void FormatStyle::FormatStyleSet::Clear() { Styles.reset(); } llvm::Optional FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const { @@ -1857,8 +1848,7 @@ static unsigned findJavaImportGroup(const FormatStyle &Style, static void sortJavaImports(const FormatStyle &Style, const SmallVectorImpl &Imports, ArrayRef Ranges, StringRef FileName, - StringRef Code, - tooling::Replacements &Replaces) { + StringRef Code, tooling::Replacements &Replaces) { unsigned ImportsBeginOffset = Imports.front().Offset; unsigned ImportsEndOffset = Imports.back().Offset + Imports.back().Text.size(); @@ -1965,7 +1955,8 @@ tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code, if (Static.contains("static")) { IsStatic = true; } - ImportsInBlock.push_back({Identifier, Line, Prev, AssociatedCommentLines, IsStatic}); + ImportsInBlock.push_back( + {Identifier, Line, Prev, AssociatedCommentLines, IsStatic}); AssociatedCommentLines.clear(); } else if (Trimmed.size() > 0 && !ImportsInBlock.empty()) { // Associating comments within the imports with the nearest import below @@ -2094,7 +2085,6 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces, if (HeaderInsertions.empty() && HeadersToDelete.empty()) return Replaces; - StringRef FileName = Replaces.begin()->getFilePath(); tooling::HeaderIncludes Includes(FileName, Code, Style.IncludeStyle); @@ -2127,7 +2117,8 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces, auto Err = Result.add(*Replace); if (Err) { llvm::consumeError(std::move(Err)); - unsigned NewOffset = Result.getShiftedCodePosition(Replace->getOffset()); + unsigned NewOffset = + Result.getShiftedCodePosition(Replace->getOffset()); auto Shifted = tooling::Replacement(FileName, NewOffset, 0, Replace->getReplacementText()); Result = Result.merge(tooling::Replacements(Shifted)); diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h index 9825b24b01..2989c760b6 100644 --- a/lib/Format/FormatToken.h +++ b/lib/Format/FormatToken.h @@ -489,8 +489,7 @@ struct FormatToken { bool opensBlockOrBlockTypeList(const FormatStyle &Style) const { if (is(TT_TemplateString) && opensScope()) return true; - return is(TT_ArrayInitializerLSquare) || - is(TT_ProtoExtensionLSquare) || + return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) || (is(tok::l_brace) && (BlockKind == BK_Block || is(TT_DictLiteral) || (!Style.Cpp11BracedListStyle && NestingLevel == 0))) || diff --git a/lib/Format/FormatTokenLexer.h b/lib/Format/FormatTokenLexer.h index 5caa915049..61a4c041d1 100644 --- a/lib/Format/FormatTokenLexer.h +++ b/lib/Format/FormatTokenLexer.h @@ -20,8 +20,8 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Format/Format.h" -#include "llvm/Support/Regex.h" #include "llvm/ADT/MapVector.h" +#include "llvm/Support/Regex.h" #include diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 9f4e1802a8..246ac781fd 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -61,7 +61,7 @@ private: if (NonTemplateLess.count(CurrentToken->Previous)) return false; - const FormatToken &Previous = *CurrentToken->Previous; // The '<'. + const FormatToken &Previous = *CurrentToken->Previous; // The '<'. if (Previous.Previous) { if (Previous.Previous->Tok.isLiteral()) return false; @@ -365,7 +365,7 @@ private: // specifier parameter, although this is technically valid: // [[foo(:)]] if (AttrTok->is(tok::colon) || - AttrTok->startsSequence(tok::identifier, tok::identifier) || + AttrTok->startsSequence(tok::identifier, tok::identifier) || AttrTok->startsSequence(tok::r_paren, tok::identifier)) return false; if (AttrTok->is(tok::ellipsis)) @@ -531,11 +531,11 @@ private: // Here, we set FirstObjCSelectorName when the end of the method call is // reached, in case it was not set already. if (!Contexts.back().FirstObjCSelectorName) { - FormatToken* Previous = CurrentToken->getPreviousNonComment(); - if (Previous && Previous->is(TT_SelectorName)) { - Previous->ObjCSelectorNameParts = 1; - Contexts.back().FirstObjCSelectorName = Previous; - } + FormatToken *Previous = CurrentToken->getPreviousNonComment(); + if (Previous && Previous->is(TT_SelectorName)) { + Previous->ObjCSelectorNameParts = 1; + Contexts.back().FirstObjCSelectorName = Previous; + } } else { Left->ParameterCount = Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts; @@ -1397,7 +1397,8 @@ private: Current.Type = Current.Previous->Type; } } else if (canBeObjCSelectorComponent(Current) && - // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen. + // FIXME(bug 36976): ObjC return types shouldn't use + // TT_CastRParen. Current.Previous && Current.Previous->is(TT_CastRParen) && Current.Previous->MatchingParen && Current.Previous->MatchingParen->Previous && @@ -2423,9 +2424,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, if (Right.isOneOf(tok::semi, tok::comma)) return false; if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) { - bool IsLightweightGeneric = - Right.MatchingParen && Right.MatchingParen->Next && - Right.MatchingParen->Next->is(tok::colon); + bool IsLightweightGeneric = Right.MatchingParen && + Right.MatchingParen->Next && + Right.MatchingParen->Next->is(tok::colon); return !IsLightweightGeneric && Style.ObjCSpaceBeforeProtocolList; } if (Right.is(tok::less) && Left.is(tok::kw_template)) @@ -2612,7 +2613,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, // Slashes occur in text protocol extension syntax: [type/type] { ... }. if (Left.is(tok::slash) || Right.is(tok::slash)) return false; - if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) && + if (Left.MatchingParen && + Left.MatchingParen->is(TT_ProtoExtensionLSquare) && Right.isOneOf(tok::l_brace, tok::less)) return !Style.Cpp11BracedListStyle; // A percent is probably part of a formatting specification, such as %lld. @@ -3129,7 +3131,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, // function f(): a is B { ... } // Do not break before is in these cases. if (Right.is(Keywords.kw_is)) { - const FormatToken* Next = Right.getNextNonComment(); + const FormatToken *Next = Right.getNextNonComment(); // If `is` is followed by a colon, it's likely that it's a dict key, so // ignore it for this check. // For example this is common in Polymer: diff --git a/lib/Format/UnwrappedLineFormatter.cpp b/lib/Format/UnwrappedLineFormatter.cpp index 99b7842577..a62755840d 100644 --- a/lib/Format/UnwrappedLineFormatter.cpp +++ b/lib/Format/UnwrappedLineFormatter.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "NamespaceEndCommentsFixer.h" #include "UnwrappedLineFormatter.h" +#include "NamespaceEndCommentsFixer.h" #include "WhitespaceManager.h" #include "llvm/Support/Debug.h" #include @@ -690,10 +690,8 @@ public: /// Formats an \c AnnotatedLine and returns the penalty. /// /// If \p DryRun is \c false, directly applies the changes. - virtual unsigned formatLine(const AnnotatedLine &Line, - unsigned FirstIndent, - unsigned FirstStartColumn, - bool DryRun) = 0; + virtual unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent, + unsigned FirstStartColumn, bool DryRun) = 0; protected: /// If the \p State's next token is an r_brace closing a nested block, @@ -1008,13 +1006,10 @@ private: } // anonymous namespace -unsigned -UnwrappedLineFormatter::format(const SmallVectorImpl &Lines, - bool DryRun, int AdditionalIndent, - bool FixBadIndentation, - unsigned FirstStartColumn, - unsigned NextStartColumn, - unsigned LastStartColumn) { +unsigned UnwrappedLineFormatter::format( + const SmallVectorImpl &Lines, bool DryRun, + int AdditionalIndent, bool FixBadIndentation, unsigned FirstStartColumn, + unsigned NextStartColumn, unsigned LastStartColumn) { LineJoiner Joiner(Style, Keywords, Lines); // Try to look up already computed penalty in DryRun-mode. diff --git a/lib/Format/UnwrappedLineFormatter.h b/lib/Format/UnwrappedLineFormatter.h index a5110f9cbd..a1ff169995 100644 --- a/lib/Format/UnwrappedLineFormatter.h +++ b/lib/Format/UnwrappedLineFormatter.h @@ -39,10 +39,8 @@ public: /// Format the current block and return the penalty. unsigned format(const SmallVectorImpl &Lines, bool DryRun = false, int AdditionalIndent = 0, - bool FixBadIndentation = false, - unsigned FirstStartColumn = 0, - unsigned NextStartColumn = 0, - unsigned LastStartColumn = 0); + bool FixBadIndentation = false, unsigned FirstStartColumn = 0, + unsigned NextStartColumn = 0, unsigned LastStartColumn = 0); private: /// Add a new line and the required indent before the first Token diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 80bfca644c..5e41564793 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -481,7 +481,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { break; case tok::identifier: if (!Tok->is(TT_StatementMacro)) - break; + break; LLVM_FALLTHROUGH; case tok::at: case tok::semi: @@ -1166,8 +1166,8 @@ void UnwrappedLineParser::parseStructuralElement() { case tok::objc_synchronized: nextToken(); if (FormatTok->Tok.is(tok::l_paren)) - // Skip synchronization object - parseParens(); + // Skip synchronization object + parseParens(); if (FormatTok->Tok.is(tok::l_brace)) { if (Style.BraceWrapping.AfterControlStatement) addUnwrappedLine(); @@ -2350,8 +2350,7 @@ void UnwrappedLineParser::parseJavaScriptEs6ImportExport() { } } -void UnwrappedLineParser::parseStatementMacro() -{ +void UnwrappedLineParser::parseStatementMacro() { nextToken(); if (FormatTok->is(tok::l_paren)) parseParens(); diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h index 153c085273..e1b35317c7 100644 --- a/lib/Format/UnwrappedLineParser.h +++ b/lib/Format/UnwrappedLineParser.h @@ -76,8 +76,7 @@ class UnwrappedLineParser { public: UnwrappedLineParser(const FormatStyle &Style, const AdditionalKeywords &Keywords, - unsigned FirstStartColumn, - ArrayRef Tokens, + unsigned FirstStartColumn, ArrayRef Tokens, UnwrappedLineConsumer &Callback); void parse(); diff --git a/lib/Format/WhitespaceManager.cpp b/lib/Format/WhitespaceManager.cpp index 44aa46f1f6..9f1ea7022f 100644 --- a/lib/Format/WhitespaceManager.cpp +++ b/lib/Format/WhitespaceManager.cpp @@ -432,19 +432,20 @@ void WhitespaceManager::alignConsecutiveAssignments() { if (!Style.AlignConsecutiveAssignments) return; - AlignTokens(Style, - [&](const Change &C) { - // Do not align on equal signs that are first on a line. - if (C.NewlinesBefore > 0) - return false; - - // Do not align on equal signs that are last on a line. - if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0) - return false; - - return C.Tok->is(tok::equal); - }, - Changes, /*StartAt=*/0); + AlignTokens( + Style, + [&](const Change &C) { + // Do not align on equal signs that are first on a line. + if (C.NewlinesBefore > 0) + return false; + + // Do not align on equal signs that are last on a line. + if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0) + return false; + + return C.Tok->is(tok::equal); + }, + Changes, /*StartAt=*/0); } void WhitespaceManager::alignConsecutiveDeclarations() { @@ -457,15 +458,16 @@ void WhitespaceManager::alignConsecutiveDeclarations() { // const char* const* v1; // float const* v2; // SomeVeryLongType const& v3; - AlignTokens(Style, - [](Change const &C) { - // tok::kw_operator is necessary for aligning operator overload - // definitions. - return C.Tok->is(TT_StartOfName) || - C.Tok->is(TT_FunctionDeclarationName) || - C.Tok->is(tok::kw_operator); - }, - Changes, /*StartAt=*/0); + AlignTokens( + Style, + [](Change const &C) { + // tok::kw_operator is necessary for aligning operator overload + // definitions. + return C.Tok->is(TT_StartOfName) || + C.Tok->is(TT_FunctionDeclarationName) || + C.Tok->is(tok::kw_operator); + }, + Changes, /*StartAt=*/0); } void WhitespaceManager::alignTrailingComments() { @@ -541,11 +543,10 @@ void WhitespaceManager::alignTrailingComments() { MinColumn = std::max(MinColumn, ChangeMinColumn); MaxColumn = std::min(MaxColumn, ChangeMaxColumn); } - BreakBeforeNext = - (i == 0) || (Changes[i].NewlinesBefore > 1) || - // Never start a sequence with a comment at the beginning of - // the line. - (Changes[i].NewlinesBefore == 1 && StartOfSequence == i); + BreakBeforeNext = (i == 0) || (Changes[i].NewlinesBefore > 1) || + // Never start a sequence with a comment at the beginning + // of the line. + (Changes[i].NewlinesBefore == 1 && StartOfSequence == i); Newlines = 0; } alignTrailingComments(StartOfSequence, Changes.size(), MinColumn); -- cgit v1.2.3