diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h index a0b63514574ed1e30a6e68daeeb61d64c61741d8..237c3e4c3b23e660f36de127cc3774c06531da39 100644 --- a/include/clang/Format/Format.h +++ b/include/clang/Format/Format.h @@ -78,4 +78,4 @@ tooling::Replacements reformat(const FormatStyle &Style, Lexer &Lex, } // end namespace format } // end namespace clang -#endif // LLVM_CLANG_FORMAT_FORMAT_H +#endif // LLVM_CLANG_FORMAT_FORMAT_H diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 7d135d9b175a63c1cc8f979d42447e576b6ea84b..93126613ec5465adbd9b74956e25337abaa6f46d 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -124,7 +124,7 @@ public: bool FitsOnALine = true; for (unsigned i = 1, n = Line.Tokens.size(); i != n; ++i) { Columns += (Annotations[i].SpaceRequiredBefore ? 1 : 0) + - Line.Tokens[i].Tok.getLength(); + Line.Tokens[i].Tok.getLength(); // A special case for the colon of a constructor initializer as this only // needs to be put on a new line if the line needs to be split. if (Columns > Style.ColumnLimit || @@ -248,8 +248,8 @@ private: // Indent and extra 4 spaces after '=' as it continues an expression. // Don't do that on the top level, as we already indent 4 there. State.Column = State.Indent[ParenLevel] + 4; - } else if (Line.Tokens[0].Tok.is(tok::kw_for) && - Previous.Tok.is(tok::comma)) { + } else if ( + Line.Tokens[0].Tok.is(tok::kw_for) && Previous.Tok.is(tok::comma)) { State.Column = State.ForLoopVariablePos; } else { State.Column = State.Indent[ParenLevel]; @@ -384,7 +384,7 @@ private: unsigned CurrentPenalty = 0; if (NewLine) { CurrentPenalty += Parameters.PenaltyIndentLevel * State.Indent.size() + - splitPenalty(State.ConsumedTokens - 1); + splitPenalty(State.ConsumedTokens - 1); } else { if (State.Indent.size() < State.StartOfLineLevel) CurrentPenalty += Parameters.PenaltyLevelDecrease * @@ -668,8 +668,9 @@ public: Annotation.SpaceRequiredBefore = true; } else if (Annotation.Type == TokenAnnotation::TT_OverloadedOperator) { Annotation.SpaceRequiredBefore = - Line.Tokens[i].Tok.is(tok::identifier) || Line.Tokens[i].Tok.is( - tok::kw_new) || Line.Tokens[i].Tok.is(tok::kw_delete); + Line.Tokens[i].Tok.is(tok::identifier) || + Line.Tokens[i].Tok.is(tok::kw_new) || + Line.Tokens[i].Tok.is(tok::kw_delete); } else if ( Annotations[i - 1].Type == TokenAnnotation::TT_OverloadedOperator) { Annotation.SpaceRequiredBefore = false; @@ -691,8 +692,8 @@ public: Annotation.MustBreakBefore = true; } else if (Line.Tokens[i].Tok.is(tok::colon)) { Annotation.SpaceRequiredBefore = - Line.Tokens[0].Tok.isNot(tok::kw_case) && !IsObjCMethodDecl && - (i != e - 1); + Line.Tokens[0].Tok.isNot(tok::kw_case) && !IsObjCMethodDecl && + (i != e - 1); // Don't break at ':' if identifier before it can beak. if (IsObjCMethodDecl && Line.Tokens[i - 1].Tok.is(tok::identifier) && Annotations[i - 1].CanBreakBefore) @@ -799,8 +800,7 @@ private: return getPrecedence(Tok) > prec::Comma; } - TokenAnnotation::TokenType determineStarAmpUsage(unsigned Index, - bool IsRHS) { + TokenAnnotation::TokenType determineStarAmpUsage(unsigned Index, bool IsRHS) { if (Index == Annotations.size()) return TokenAnnotation::TT_Unknown; @@ -866,8 +866,8 @@ private: return false; if (Right.is(tok::amp) || Right.is(tok::star)) return Left.isLiteral() || - (Left.isNot(tok::star) && Left.isNot(tok::amp) && - !Style.PointerAndReferenceBindToType); + (Left.isNot(tok::star) && Left.isNot(tok::amp) && + !Style.PointerAndReferenceBindToType); if (Left.is(tok::amp) || Left.is(tok::star)) return Right.isLiteral() || Style.PointerAndReferenceBindToType; if (Right.is(tok::star) && Left.is(tok::l_paren)) @@ -889,9 +889,9 @@ private: return false; if (Right.is(tok::l_paren)) { return Left.is(tok::kw_if) || Left.is(tok::kw_for) || - Left.is(tok::kw_while) || Left.is(tok::kw_switch) || - (Left.isNot(tok::identifier) && Left.isNot(tok::kw_sizeof) && - Left.isNot(tok::kw_typeof)); + Left.is(tok::kw_while) || Left.is(tok::kw_switch) || + (Left.isNot(tok::identifier) && Left.isNot(tok::kw_sizeof) && + Left.isNot(tok::kw_typeof)); } return true; } @@ -901,11 +901,11 @@ private: Right.Tok.is(tok::comment) || Right.Tok.is(tok::greater)) return false; return (isBinaryOperator(Left) && Left.Tok.isNot(tok::lessless)) || - Left.Tok.is(tok::comma) || Right.Tok.is(tok::lessless) || - Right.Tok.is(tok::arrow) || Right.Tok.is(tok::period) || - Right.Tok.is(tok::colon) || Left.Tok.is(tok::semi) || - Left.Tok.is(tok::l_brace) || - (Left.Tok.is(tok::l_paren) && !Right.Tok.is(tok::r_paren)); + Left.Tok.is(tok::comma) || Right.Tok.is(tok::lessless) || + Right.Tok.is(tok::arrow) || Right.Tok.is(tok::period) || + Right.Tok.is(tok::colon) || Left.Tok.is(tok::semi) || + Left.Tok.is(tok::l_brace) || + (Left.Tok.is(tok::l_paren) && !Right.Tok.is(tok::r_paren)); } const UnwrappedLine &Line; diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 7e91cb4351ff79cb52bf75655baa023a1e2140f6..6c035b001c78a995ef786c863a27cd48ff8aae66 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -25,9 +25,7 @@ namespace format { UnwrappedLineParser::UnwrappedLineParser(const FormatStyle &Style, FormatTokenSource &Tokens, UnwrappedLineConsumer &Callback) - : Style(Style), - Tokens(Tokens), - Callback(Callback) { + : Style(Style), Tokens(Tokens), Callback(Callback) { } bool UnwrappedLineParser::parse() { diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h index 287194f2a627c644e4f909842a077a574c9f5a9e..ccf437f50744b1b5ae245f75019c6b52eab1743e 100644 --- a/lib/Format/UnwrappedLineParser.h +++ b/lib/Format/UnwrappedLineParser.h @@ -123,4 +123,4 @@ private: } // end namespace format } // end namespace clang -#endif // LLVM_CLANG_FORMAT_UNWRAPPED_LINE_PARSER_H +#endif // LLVM_CLANG_FORMAT_UNWRAPPED_LINE_PARSER_H