From: Daniel Jasper Date: Mon, 8 Jul 2013 14:34:09 +0000 (+0000) Subject: Reformat clang-format's source files after r185822 and others. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a409b62126d8f0b8f5749d5ed435ad2b394b526;p=clang Reformat clang-format's source files after r185822 and others. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185823 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index f01b481b84..816fd237bb 100644 --- a/lib/Format/BreakableToken.cpp +++ b/lib/Format/BreakableToken.cpp @@ -28,13 +28,13 @@ namespace format { static const char *const Blanks = " \t\v\f"; static bool IsBlank(char C) { switch (C) { - case ' ': - case '\t': - case '\v': - case '\f': - return true; - default: - return false; + case ' ': + case '\t': + case '\v': + case '\f': + return true; + default: + return false; } } @@ -388,9 +388,9 @@ BreakableBlockComment::replaceWhitespaceBefore(unsigned LineIndex, } } - unsigned WhitespaceOffsetInToken = - Lines[LineIndex].data() - Tok.TokenText.data() - - LeadingWhitespace[LineIndex]; + unsigned WhitespaceOffsetInToken = Lines[LineIndex].data() - + Tok.TokenText.data() - + LeadingWhitespace[LineIndex]; assert(StartOfLineColumn[LineIndex] >= Prefix.size()); Whitespaces.replaceWhitespaceInToken( Tok, WhitespaceOffsetInToken, LeadingWhitespace[LineIndex], "", Prefix, diff --git a/lib/Format/BreakableToken.h b/lib/Format/BreakableToken.h index afcc8b83a5..90b78ac03a 100644 --- a/lib/Format/BreakableToken.h +++ b/lib/Format/BreakableToken.h @@ -48,8 +48,8 @@ public: /// specified from the start of the (original) line. /// \p Length can be set to StringRef::npos, which means "to the end of line". virtual unsigned - getLineLengthAfterSplit(unsigned LineIndex, unsigned Offset, - StringRef::size_type Length) const = 0; + getLineLengthAfterSplit(unsigned LineIndex, unsigned Offset, + StringRef::size_type Length) const = 0; /// \brief Returns a range (offset, length) at which to break the line at /// \p LineIndex, if previously broken at \p TailOffset. If possible, do not diff --git a/lib/Format/Encoding.h b/lib/Format/Encoding.h index a44f4590a2..e9e9ae71c7 100644 --- a/lib/Format/Encoding.h +++ b/lib/Format/Encoding.h @@ -50,10 +50,10 @@ inline unsigned getCodePointCountUTF8(StringRef Text) { /// Encoding. inline unsigned getCodePointCount(StringRef Text, Encoding Encoding) { switch (Encoding) { - case Encoding_UTF8: - return getCodePointCountUTF8(Text); - default: - return Text.size(); + case Encoding_UTF8: + return getCodePointCountUTF8(Text); + default: + return Text.size(); } } @@ -61,16 +61,14 @@ inline unsigned getCodePointCount(StringRef Text, Encoding Encoding) { /// codepoint and starting with FirstChar in the specified Encoding. inline unsigned getCodePointNumBytes(char FirstChar, Encoding Encoding) { switch (Encoding) { - case Encoding_UTF8: - return getNumBytesForUTF8(FirstChar); - default: - return 1; + case Encoding_UTF8: + return getNumBytesForUTF8(FirstChar); + default: + return 1; } } -inline bool isOctDigit(char c) { - return '0' <= c && c <= '7'; -} +inline bool isOctDigit(char c) { return '0' <= c && c <= '7'; } inline bool isHexDigit(char c) { return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 0b0092d31f..e4004a649b 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -271,9 +271,9 @@ public: LineState State; State.Column = FirstIndent; State.NextToken = RootToken; - State.Stack.push_back( - ParenState(FirstIndent, FirstIndent, /*AvoidBinPacking=*/false, - /*NoLineBreak=*/false)); + State.Stack.push_back(ParenState(FirstIndent, FirstIndent, + /*AvoidBinPacking=*/false, + /*NoLineBreak=*/false)); State.LineContainsContinuedForLoopSection = false; State.ParenLevel = 0; State.StartOfStringLiteral = 0; @@ -1289,9 +1289,9 @@ public: !AnnotatedLines[i].First->Next) AnnotatedLines[i].Level = NextNonCommentLine->Level; else - NextNonCommentLine = - AnnotatedLines[i].First->isNot(tok::r_brace) ? &AnnotatedLines[i] - : NULL; + NextNonCommentLine = AnnotatedLines[i].First->isNot(tok::r_brace) + ? &AnnotatedLines[i] + : NULL; } std::vector IndentForLevel; diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h index 94425550b9..69afaac965 100644 --- a/lib/Format/FormatToken.h +++ b/lib/Format/FormatToken.h @@ -212,7 +212,6 @@ struct FormatToken { bool opensScope() const { return isOneOf(tok::l_paren, tok::l_brace, tok::l_square) || Type == TT_TemplateOpener; - } /// \brief Returns whether \p Tok is )]} or a template closing >. bool closesScope() const { diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 8db28635e8..1bcdac8e21 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -542,9 +542,9 @@ private: ScopedContextCreator(AnnotatingParser &P, tok::TokenKind ContextKind, unsigned Increase) : P(P) { - P.Contexts.push_back( - Context(ContextKind, P.Contexts.back().BindingStrength + Increase, - P.Contexts.back().IsExpression)); + P.Contexts.push_back(Context(ContextKind, + P.Contexts.back().BindingStrength + Increase, + P.Contexts.back().IsExpression)); } ~ScopedContextCreator() { P.Contexts.pop_back(); } @@ -625,8 +625,7 @@ private: if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf && Contexts.back().IsExpression) IsCast = true; - if (Current.Next && - Current.Next->isNot(tok::string_literal) && + if (Current.Next && Current.Next->isNot(tok::string_literal) && (Current.Next->Tok.isLiteral() || Current.Next->isOneOf(tok::kw_sizeof, tok::kw_alignof))) IsCast = true; @@ -678,9 +677,9 @@ private: if (PreviousNotConst == NULL) return false; - bool IsPPKeyword = - PreviousNotConst->is(tok::identifier) && PreviousNotConst->Previous && - PreviousNotConst->Previous->is(tok::hash); + bool IsPPKeyword = PreviousNotConst->is(tok::identifier) && + PreviousNotConst->Previous && + PreviousNotConst->Previous->is(tok::hash); return (!IsPPKeyword && PreviousNotConst->is(tok::identifier)) || PreviousNotConst->Type == TT_PointerOrReference || @@ -952,9 +951,9 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { if (Current->MustBreakBefore) Current->TotalLength = Current->Previous->TotalLength + Style.ColumnLimit; else - Current->TotalLength = - Current->Previous->TotalLength + Current->CodePointCount + - Current->SpacesRequiredBefore; + Current->TotalLength = Current->Previous->TotalLength + + Current->CodePointCount + + Current->SpacesRequiredBefore; // FIXME: Only calculate this if CanBreakBefore is true once static // initializers etc. are sorted out. // FIXME: Move magic numbers to a better place. diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h index 227b023a81..fb65078c33 100644 --- a/lib/Format/UnwrappedLineParser.h +++ b/lib/Format/UnwrappedLineParser.h @@ -31,8 +31,7 @@ namespace format { /// \c UnwrappedLineFormatter. The key property is that changing the formatting /// within an unwrapped line does not affect any other unwrapped lines. struct UnwrappedLine { - UnwrappedLine() : Level(0), InPPDirective(false), MustBeDeclaration(false) { - } + UnwrappedLine() : Level(0), InPPDirective(false), MustBeDeclaration(false) {} // FIXME: Don't use std::list here. /// \brief The \c Tokens comprising this \c UnwrappedLine. @@ -49,8 +48,7 @@ struct UnwrappedLine { class UnwrappedLineConsumer { public: - virtual ~UnwrappedLineConsumer() { - } + virtual ~UnwrappedLineConsumer() {} virtual void consumeUnwrappedLine(const UnwrappedLine &Line) = 0; }; @@ -163,8 +161,8 @@ private: // Represents preprocessor branch type, so we can find matching // #if/#else/#endif directives. enum PPBranchKind { - PP_Conditional, // Any #if, #ifdef, #ifndef, #elif, block outside #if 0 - PP_Unreachable // #if 0 or a conditional preprocessor block inside #if 0 + PP_Conditional, // Any #if, #ifdef, #ifndef, #elif, block outside #if 0 + PP_Unreachable // #if 0 or a conditional preprocessor block inside #if 0 }; // Keeps a stack of currently active preprocessor branching directives. diff --git a/lib/Format/WhitespaceManager.cpp b/lib/Format/WhitespaceManager.cpp index 90f856bd11..3805278de7 100644 --- a/lib/Format/WhitespaceManager.cpp +++ b/lib/Format/WhitespaceManager.cpp @@ -42,9 +42,9 @@ void WhitespaceManager::replaceWhitespace(const FormatToken &Tok, unsigned Newlines, unsigned Spaces, unsigned StartOfTokenColumn, bool InPPDirective) { - Changes.push_back( - Change(true, Tok.WhitespaceRange, Spaces, StartOfTokenColumn, Newlines, - "", "", Tok.Tok.getKind(), InPPDirective && !Tok.IsFirst)); + Changes.push_back(Change(true, Tok.WhitespaceRange, Spaces, + StartOfTokenColumn, Newlines, "", "", + Tok.Tok.getKind(), InPPDirective && !Tok.IsFirst)); } void WhitespaceManager::addUntouchableToken(const FormatToken &Tok, @@ -94,10 +94,10 @@ void WhitespaceManager::calculateLineBreakInformation() { SourceMgr.getFileOffset(Changes[i].OriginalWhitespaceRange.getBegin()); unsigned PreviousOriginalWhitespaceEnd = SourceMgr.getFileOffset( Changes[i - 1].OriginalWhitespaceRange.getEnd()); - Changes[i - 1].TokenLength = - OriginalWhitespaceStart - PreviousOriginalWhitespaceEnd + - Changes[i].PreviousLinePostfix.size() + - Changes[i - 1].CurrentLinePrefix.size(); + Changes[i - 1].TokenLength = OriginalWhitespaceStart - + PreviousOriginalWhitespaceEnd + + Changes[i].PreviousLinePostfix.size() + + Changes[i - 1].CurrentLinePrefix.size(); Changes[i].PreviousEndOfTokenColumn = Changes[i - 1].StartOfTokenColumn + Changes[i - 1].TokenLength; @@ -242,8 +242,7 @@ void WhitespaceManager::storeReplacement(const SourceRange &Range, SourceMgr.getFileOffset(Range.getBegin()); // Don't create a replacement, if it does not change anything. if (StringRef(SourceMgr.getCharacterData(Range.getBegin()), - WhitespaceLength) == - Text) + WhitespaceLength) == Text) return; Replaces.insert(tooling::Replacement( SourceMgr, CharSourceRange::getCharRange(Range), Text)); diff --git a/lib/Format/WhitespaceManager.h b/lib/Format/WhitespaceManager.h index 11167fa4c3..9ca3480637 100644 --- a/lib/Format/WhitespaceManager.h +++ b/lib/Format/WhitespaceManager.h @@ -75,11 +75,11 @@ private: struct Change { /// \brief Functor to sort changes in original source order. class IsBeforeInFile { - public: + public: IsBeforeInFile(const SourceManager &SourceMgr) : SourceMgr(SourceMgr) {} bool operator()(const Change &C1, const Change &C2) const; - private: + private: const SourceManager &SourceMgr; }; @@ -126,7 +126,6 @@ private: unsigned TokenLength; unsigned PreviousEndOfTokenColumn; unsigned EscapedNewlineColumn; - }; /// \brief Calculate \c IsTrailingComment, \c TokenLength for the last tokens