<div dir="ltr">Yes ideally I'd agree, It also says:<div><br></div><div>> <span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px">Avoid committing formatting- or whitespace-only changes outside of code you plan to make subsequent changes to. </span></div><div><br></div><div>This was getting to be a problem, every time we edited the file (with auto-clang-format) a large number of other changes would also get made, presumably because others hadn't been clang-formatting their commits correctly! we'd have to merge out a lot of changes everytime.</div><div><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px">And then its says this..</span> </div><div> <span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px">>Also, try to separate formatting or whitespace changes from functional changes, either by correcting the format first (ideally) or afterward</span></div><div><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px"><br></span></div><div><font color="#000000" face="Lucida Grande, Lucida Sans Unicode, Geneva, Verdana, sans-serif"><span style="font-size:14px">which means you want those changes to be separate commits.. so ideally its better we clang-format the file when there is no other related changes so future revisions don't need to have a mixture of real changes and whitespace changes.</span></font></div><div><font color="#000000" face="Lucida Grande, Lucida Sans Unicode, Geneva, Verdana, sans-serif"><span style="font-size:14px"><br></span></font></div><div><font color="#000000" face="Lucida Grande, Lucida Sans Unicode, Geneva, Verdana, sans-serif"><span style="font-size:14px">I also think given we also encourage people to clang-format out code,  its ironic clang-format itself is not clang-formatted!</span></font></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 8, 2019 at 8:59 PM Michael Kruse <<a href="mailto:llvm-commits@meinersbur.de">llvm-commits@meinersbur.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Isn't this kind of commit discouraged?, as by<br>
<a href="https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access" rel="noreferrer" target="_blank">https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access</a><br>
<br>
> Avoid committing formatting- or whitespace-only changes outside of code you plan to make subsequent changes to.<br>
<br>
and the discussion after which this has been added:<br>
<a href="https://lists.llvm.org/pipermail/llvm-dev/2018-July/124941.html" rel="noreferrer" target="_blank">https://lists.llvm.org/pipermail/llvm-dev/2018-July/124941.html</a><br>
<br>
<br>
Michael<br>
<br>
Am Fr., 1. März 2019 um 03:09 Uhr schrieb Paul Hoad via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>:<br>
><br>
> Author: paulhoad<br>
> Date: Fri Mar  1 01:09:54 2019<br>
> New Revision: 355182<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=355182&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=355182&view=rev</a><br>
> Log:<br>
> [clang-format] [NFC] clang-format the Format library<br>
><br>
> 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.<br>
><br>
> Commit a non functional change using latest build Windows clang-format r351376 with no other changes, to remove these differences<br>
><br>
> All FormatTests<br>
> pass [==========] 652 tests from 20 test cases ran.<br>
><br>
> Modified:<br>
>     cfe/trunk/lib/Format/BreakableToken.cpp<br>
>     cfe/trunk/lib/Format/BreakableToken.h<br>
>     cfe/trunk/lib/Format/ContinuationIndenter.cpp<br>
>     cfe/trunk/lib/Format/Format.cpp<br>
>     cfe/trunk/lib/Format/FormatToken.h<br>
>     cfe/trunk/lib/Format/FormatTokenLexer.h<br>
>     cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
>     cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp<br>
>     cfe/trunk/lib/Format/UnwrappedLineFormatter.h<br>
>     cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
>     cfe/trunk/lib/Format/UnwrappedLineParser.h<br>
>     cfe/trunk/lib/Format/WhitespaceManager.cpp<br>
><br>
> Modified: cfe/trunk/lib/Format/BreakableToken.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/BreakableToken.cpp (original)<br>
> +++ cfe/trunk/lib/Format/BreakableToken.cpp Fri Mar  1 01:09:54 2019<br>
> @@ -62,12 +62,10 @@ static StringRef getLineCommentIndentPre<br>
>    return LongestPrefix;<br>
>  }<br>
><br>
> -static BreakableToken::Split getCommentSplit(StringRef Text,<br>
> -                                             unsigned ContentStartColumn,<br>
> -                                             unsigned ColumnLimit,<br>
> -                                             unsigned TabWidth,<br>
> -                                             encoding::Encoding Encoding,<br>
> -                                             const FormatStyle &Style) {<br>
> +static BreakableToken::Split<br>
> +getCommentSplit(StringRef Text, unsigned ContentStartColumn,<br>
> +                unsigned ColumnLimit, unsigned TabWidth,<br>
> +                encoding::Encoding Encoding, const FormatStyle &Style) {<br>
>    LLVM_DEBUG(llvm::dbgs() << "Comment split: \"" << Text<br>
>                            << "\", Column limit: " << ColumnLimit<br>
>                            << ", Content start: " << ContentStartColumn << "\n");<br>
> @@ -191,7 +189,7 @@ bool switchesFormatting(const FormatToke<br>
><br>
>  unsigned<br>
>  BreakableToken::getLengthAfterCompression(unsigned RemainingTokenColumns,<br>
> -                                              Split Split) const {<br>
> +                                          Split Split) const {<br>
>    // Example: consider the content<br>
>    // lala  lala<br>
>    // - RemainingTokenColumns is the original number of columns, 10;<br>
> @@ -870,23 +868,20 @@ void BreakableLineCommentSection::reflow<br>
>      // the next line.<br>
>      unsigned WhitespaceLength =<br>
>          Lines[LineIndex].data() - tokenAt(LineIndex).TokenText.data() - Offset;<br>
> -    Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex],<br>
> -                                         Offset,<br>
> +    Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], Offset,<br>
>                                           /*ReplaceChars=*/WhitespaceLength,<br>
>                                           /*PreviousPostfix=*/"",<br>
>                                           /*CurrentPrefix=*/"",<br>
>                                           /*InPPDirective=*/false,<br>
>                                           /*Newlines=*/0,<br>
>                                           /*Spaces=*/0);<br>
> -<br>
>    }<br>
>    // Replace the indent and prefix of the token with the reflow prefix.<br>
>    unsigned Offset =<br>
>        Lines[LineIndex].data() - tokenAt(LineIndex).TokenText.data();<br>
>    unsigned WhitespaceLength =<br>
>        Content[LineIndex].data() - Lines[LineIndex].data();<br>
> -  Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex],<br>
> -                                       Offset,<br>
> +  Whitespaces.replaceWhitespaceInToken(*Tokens[LineIndex], Offset,<br>
>                                         /*ReplaceChars=*/WhitespaceLength,<br>
>                                         /*PreviousPostfix=*/"",<br>
>                                         /*CurrentPrefix=*/ReflowPrefix,<br>
><br>
> Modified: cfe/trunk/lib/Format/BreakableToken.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.h?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.h?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/BreakableToken.h (original)<br>
> +++ cfe/trunk/lib/Format/BreakableToken.h Fri Mar  1 01:09:54 2019<br>
> @@ -146,9 +146,7 @@ public:<br>
>    //  * @param loooooooooooooong line<br>
>    //  *     continuation<br>
>    //  */<br>
> -  virtual unsigned getContentIndent(unsigned LineIndex) const {<br>
> -    return 0;<br>
> -  }<br>
> +  virtual unsigned getContentIndent(unsigned LineIndex) const { return 0; }<br>
><br>
>    /// Returns a range (offset, length) at which to break the line at<br>
>    /// \p LineIndex, if previously broken at \p TailOffset. If possible, do not<br>
> @@ -202,9 +200,7 @@ public:<br>
><br>
>    /// Returns whether there will be a line break at the start of the<br>
>    /// token.<br>
> -  virtual bool introducesBreakBeforeToken() const {<br>
> -    return false;<br>
> -  }<br>
> +  virtual bool introducesBreakBeforeToken() const { return false; }<br>
><br>
>    /// Replaces the whitespace between \p LineIndex-1 and \p LineIndex.<br>
>    virtual void adaptStartOfLine(unsigned LineIndex,<br>
><br>
> Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)<br>
> +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Mar  1 01:09:54 2019<br>
> @@ -403,8 +403,7 @@ bool ContinuationIndenter::mustBreak(con<br>
>        // FIXME: We should find a more generic solution to this problem.<br>
>        !(State.Column <= NewLineColumn &&<br>
>          Style.Language == FormatStyle::LK_JavaScript) &&<br>
> -      !(Previous.closesScopeAfterBlock() &&<br>
> -        State.Column <= NewLineColumn))<br>
> +      !(Previous.closesScopeAfterBlock() && State.Column <= NewLineColumn))<br>
>      return true;<br>
><br>
>    // If the template declaration spans multiple lines, force wrap before the<br>
> @@ -835,8 +834,8 @@ unsigned ContinuationIndenter::addTokenO<br>
>        // about removing empty lines on closing blocks. Special case them here.<br>
>        MaxEmptyLinesToKeep = 1;<br>
>      }<br>
> -    unsigned Newlines = std::max(<br>
> -        1u, std::min(Current.NewlinesBefore, MaxEmptyLinesToKeep));<br>
> +    unsigned Newlines =<br>
> +        std::max(1u, std::min(Current.NewlinesBefore, MaxEmptyLinesToKeep));<br>
>      bool ContinuePPDirective =<br>
>          State.Line->InPPDirective && State.Line->Type != LT_ImportStatement;<br>
>      Whitespaces.replaceWhitespace(Current, Newlines, State.Column, State.Column,<br>
> @@ -1168,8 +1167,7 @@ unsigned ContinuationIndenter::moveState<br>
>    State.Column += Current.ColumnWidth;<br>
>    State.NextToken = State.NextToken->Next;<br>
><br>
> -  unsigned Penalty =<br>
> -      handleEndOfLine(Current, State, DryRun, AllowBreak);<br>
> +  unsigned Penalty = handleEndOfLine(Current, State, DryRun, AllowBreak);<br>
><br>
>    if (Current.Role)<br>
>      Current.Role->formatFromToken(State, this, DryRun);<br>
> @@ -1530,9 +1528,8 @@ unsigned ContinuationIndenter::reformatR<br>
>    //     that raw string prefix starts, and<br>
>    //   - if the raw string prefix does not start on a newline, it is the current<br>
>    //     indent.<br>
> -  unsigned LastStartColumn = Current.NewlinesBefore<br>
> -                                 ? FirstStartColumn - NewPrefixSize<br>
> -                                 : CurrentIndent;<br>
> +  unsigned LastStartColumn =<br>
> +      Current.NewlinesBefore ? FirstStartColumn - NewPrefixSize : CurrentIndent;<br>
><br>
>    std::pair<tooling::Replacements, unsigned> Fixes = internal::reformat(<br>
>        RawStringStyle, RawText, {tooling::Range(0, RawText.size())},<br>
> @@ -1589,8 +1586,9 @@ unsigned ContinuationIndenter::reformatR<br>
>    // have to manually add the penalty for the prefix R"delim( over the column<br>
>    // limit.<br>
>    unsigned PrefixExcessCharacters =<br>
> -      StartColumn + NewPrefixSize > Style.ColumnLimit ?<br>
> -      StartColumn + NewPrefixSize - Style.ColumnLimit : 0;<br>
> +      StartColumn + NewPrefixSize > Style.ColumnLimit<br>
> +          ? StartColumn + NewPrefixSize - Style.ColumnLimit<br>
> +          : 0;<br>
>    bool IsMultiline =<br>
>        ContentStartsOnNewline || (NewCode->find('\n') != std::string::npos);<br>
>    if (IsMultiline) {<br>
> @@ -1708,16 +1706,16 @@ ContinuationIndenter::getRawStringStyle(<br>
>    return RawStringStyle;<br>
>  }<br>
><br>
> -std::unique_ptr<BreakableToken> ContinuationIndenter::createBreakableToken(<br>
> -    const FormatToken &Current, LineState &State, bool AllowBreak) {<br>
> +std::unique_ptr<BreakableToken><br>
> +ContinuationIndenter::createBreakableToken(const FormatToken &Current,<br>
> +                                           LineState &State, bool AllowBreak) {<br>
>    unsigned StartColumn = State.Column - Current.ColumnWidth;<br>
>    if (Current.isStringLiteral()) {<br>
>      // FIXME: String literal breaking is currently disabled for Java and JS, as<br>
>      // it requires strings to be merged using "+" which we don't support.<br>
>      if (Style.Language == FormatStyle::LK_Java ||<br>
>          Style.Language == FormatStyle::LK_JavaScript ||<br>
> -        !Style.BreakStringLiterals ||<br>
> -        !AllowBreak)<br>
> +        !Style.BreakStringLiterals || !AllowBreak)<br>
>        return nullptr;<br>
><br>
>      // Don't break string literals inside preprocessor directives (except for<br>
><br>
> Modified: cfe/trunk/lib/Format/Format.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/Format.cpp (original)<br>
> +++ cfe/trunk/lib/Format/Format.cpp Fri Mar  1 01:09:54 2019<br>
> @@ -149,8 +149,8 @@ struct ScalarEnumerationTraits<FormatSty<br>
><br>
>  template <><br>
>  struct ScalarEnumerationTraits<FormatStyle::BreakInheritanceListStyle> {<br>
> -  static void<br>
> -  enumeration(IO &IO, FormatStyle::BreakInheritanceListStyle &Value) {<br>
> +  static void enumeration(IO &IO,<br>
> +                          FormatStyle::BreakInheritanceListStyle &Value) {<br>
>      IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon);<br>
>      IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma);<br>
>      IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon);<br>
> @@ -179,7 +179,8 @@ struct ScalarEnumerationTraits<FormatSty<br>
><br>
>  template <><br>
>  struct ScalarEnumerationTraits<FormatStyle::BreakTemplateDeclarationsStyle> {<br>
> -  static void enumeration(IO &IO, FormatStyle::BreakTemplateDeclarationsStyle &Value) {<br>
> +  static void enumeration(IO &IO,<br>
> +                          FormatStyle::BreakTemplateDeclarationsStyle &Value) {<br>
>      IO.enumCase(Value, "No", FormatStyle::BTDS_No);<br>
>      IO.enumCase(Value, "MultiLine", FormatStyle::BTDS_MultiLine);<br>
>      IO.enumCase(Value, "Yes", FormatStyle::BTDS_Yes);<br>
> @@ -361,10 +362,8 @@ template <> struct MappingTraits<FormatS<br>
>      IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces);<br>
><br>
>      bool BreakBeforeInheritanceComma = false;<br>
> -    IO.mapOptional("BreakBeforeInheritanceComma",<br>
> -                   BreakBeforeInheritanceComma);<br>
> -    IO.mapOptional("BreakInheritanceList",<br>
> -                   Style.BreakInheritanceList);<br>
> +    IO.mapOptional("BreakBeforeInheritanceComma", BreakBeforeInheritanceComma);<br>
> +    IO.mapOptional("BreakInheritanceList", Style.BreakInheritanceList);<br>
>      // If BreakBeforeInheritanceComma was specified but<br>
>      // BreakInheritance was not, initialize the latter from the<br>
>      // former for backwards compatibility.<br>
> @@ -854,15 +853,9 @@ FormatStyle getChromiumStyle(FormatStyle<br>
>      // See styleguide for import groups:<br>
>      // <a href="https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order" rel="noreferrer" target="_blank">https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order</a><br>
>      ChromiumStyle.JavaImportGroups = {<br>
> -        "android",<br>
> -        "com",<br>
> -        "dalvik",<br>
> -        "junit",<br>
> -        "org",<br>
> -        "com.google.android.apps.chrome",<br>
> -        "org.chromium",<br>
> -        "java",<br>
> -        "javax",<br>
> +        "android",      "com",  "dalvik",<br>
> +        "junit",        "org",  "com.google.android.apps.chrome",<br>
> +        "org.chromium", "java", "javax",<br>
>      };<br>
>      ChromiumStyle.SortIncludes = true;<br>
>    } else if (Language == FormatStyle::LK_JavaScript) {<br>
> @@ -1063,9 +1056,7 @@ void FormatStyle::FormatStyleSet::Add(Fo<br>
>    (*Styles)[Style.Language] = std::move(Style);<br>
>  }<br>
><br>
> -void FormatStyle::FormatStyleSet::Clear() {<br>
> -  Styles.reset();<br>
> -}<br>
> +void FormatStyle::FormatStyleSet::Clear() { Styles.reset(); }<br>
><br>
>  llvm::Optional<FormatStyle><br>
>  FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {<br>
> @@ -1857,8 +1848,7 @@ static unsigned findJavaImportGroup(cons<br>
>  static void sortJavaImports(const FormatStyle &Style,<br>
>                              const SmallVectorImpl<JavaImportDirective> &Imports,<br>
>                              ArrayRef<tooling::Range> Ranges, StringRef FileName,<br>
> -                            StringRef Code,<br>
> -                            tooling::Replacements &Replaces) {<br>
> +                            StringRef Code, tooling::Replacements &Replaces) {<br>
>    unsigned ImportsBeginOffset = Imports.front().Offset;<br>
>    unsigned ImportsEndOffset =<br>
>        Imports.back().Offset + Imports.back().Text.size();<br>
> @@ -1965,7 +1955,8 @@ tooling::Replacements sortJavaImports(co<br>
>        if (Static.contains("static")) {<br>
>          IsStatic = true;<br>
>        }<br>
> -      ImportsInBlock.push_back({Identifier, Line, Prev, AssociatedCommentLines, IsStatic});<br>
> +      ImportsInBlock.push_back(<br>
> +          {Identifier, Line, Prev, AssociatedCommentLines, IsStatic});<br>
>        AssociatedCommentLines.clear();<br>
>      } else if (Trimmed.size() > 0 && !ImportsInBlock.empty()) {<br>
>        // Associating comments within the imports with the nearest import below<br>
> @@ -2094,7 +2085,6 @@ fixCppIncludeInsertions(StringRef Code,<br>
>    if (HeaderInsertions.empty() && HeadersToDelete.empty())<br>
>      return Replaces;<br>
><br>
> -<br>
>    StringRef FileName = Replaces.begin()->getFilePath();<br>
>    tooling::HeaderIncludes Includes(FileName, Code, Style.IncludeStyle);<br>
><br>
> @@ -2127,7 +2117,8 @@ fixCppIncludeInsertions(StringRef Code,<br>
>        auto Err = Result.add(*Replace);<br>
>        if (Err) {<br>
>          llvm::consumeError(std::move(Err));<br>
> -        unsigned NewOffset = Result.getShiftedCodePosition(Replace->getOffset());<br>
> +        unsigned NewOffset =<br>
> +            Result.getShiftedCodePosition(Replace->getOffset());<br>
>          auto Shifted = tooling::Replacement(FileName, NewOffset, 0,<br>
>                                              Replace->getReplacementText());<br>
>          Result = Result.merge(tooling::Replacements(Shifted));<br>
><br>
> Modified: cfe/trunk/lib/Format/FormatToken.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/FormatToken.h (original)<br>
> +++ cfe/trunk/lib/Format/FormatToken.h Fri Mar  1 01:09:54 2019<br>
> @@ -489,8 +489,7 @@ struct FormatToken {<br>
>    bool opensBlockOrBlockTypeList(const FormatStyle &Style) const {<br>
>      if (is(TT_TemplateString) && opensScope())<br>
>        return true;<br>
> -    return is(TT_ArrayInitializerLSquare) ||<br>
> -           is(TT_ProtoExtensionLSquare) ||<br>
> +    return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) ||<br>
>             (is(tok::l_brace) &&<br>
>              (BlockKind == BK_Block || is(TT_DictLiteral) ||<br>
>               (!Style.Cpp11BracedListStyle && NestingLevel == 0))) ||<br>
><br>
> Modified: cfe/trunk/lib/Format/FormatTokenLexer.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.h?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.h?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/FormatTokenLexer.h (original)<br>
> +++ cfe/trunk/lib/Format/FormatTokenLexer.h Fri Mar  1 01:09:54 2019<br>
> @@ -20,8 +20,8 @@<br>
>  #include "clang/Basic/SourceLocation.h"<br>
>  #include "clang/Basic/SourceManager.h"<br>
>  #include "clang/Format/Format.h"<br>
> -#include "llvm/Support/Regex.h"<br>
>  #include "llvm/ADT/MapVector.h"<br>
> +#include "llvm/Support/Regex.h"<br>
><br>
>  #include <stack><br>
><br>
><br>
> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Mar  1 01:09:54 2019<br>
> @@ -61,7 +61,7 @@ private:<br>
>      if (NonTemplateLess.count(CurrentToken->Previous))<br>
>        return false;<br>
><br>
> -    const FormatToken &Previous = *CurrentToken->Previous;  // The '<'.<br>
> +    const FormatToken &Previous = *CurrentToken->Previous; // The '<'.<br>
>      if (Previous.Previous) {<br>
>        if (Previous.Previous->Tok.isLiteral())<br>
>          return false;<br>
> @@ -365,7 +365,7 @@ private:<br>
>        // specifier parameter, although this is technically valid:<br>
>        // [[foo(:)]]<br>
>        if (AttrTok->is(tok::colon) ||<br>
> -          AttrTok->startsSequence(tok::identifier, tok::identifier) ||<br>
> +          AttrTok->startsSequence(tok::identifier, tok::identifier) ||<br>
>            AttrTok->startsSequence(tok::r_paren, tok::identifier))<br>
>          return false;<br>
>        if (AttrTok->is(tok::ellipsis))<br>
> @@ -531,11 +531,11 @@ private:<br>
>          // Here, we set FirstObjCSelectorName when the end of the method call is<br>
>          // reached, in case it was not set already.<br>
>          if (!Contexts.back().FirstObjCSelectorName) {<br>
> -            FormatToken* Previous = CurrentToken->getPreviousNonComment();<br>
> -            if (Previous && Previous->is(TT_SelectorName)) {<br>
> -              Previous->ObjCSelectorNameParts = 1;<br>
> -              Contexts.back().FirstObjCSelectorName = Previous;<br>
> -            }<br>
> +          FormatToken *Previous = CurrentToken->getPreviousNonComment();<br>
> +          if (Previous && Previous->is(TT_SelectorName)) {<br>
> +            Previous->ObjCSelectorNameParts = 1;<br>
> +            Contexts.back().FirstObjCSelectorName = Previous;<br>
> +          }<br>
>          } else {<br>
>            Left->ParameterCount =<br>
>                Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts;<br>
> @@ -1397,7 +1397,8 @@ private:<br>
>          Current.Type = Current.Previous->Type;<br>
>        }<br>
>      } else if (canBeObjCSelectorComponent(Current) &&<br>
> -               // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.<br>
> +               // FIXME(bug 36976): ObjC return types shouldn't use<br>
> +               // TT_CastRParen.<br>
>                 Current.Previous && Current.Previous->is(TT_CastRParen) &&<br>
>                 Current.Previous->MatchingParen &&<br>
>                 Current.Previous->MatchingParen->Previous &&<br>
> @@ -2423,9 +2424,9 @@ bool TokenAnnotator::spaceRequiredBetwee<br>
>    if (Right.isOneOf(tok::semi, tok::comma))<br>
>      return false;<br>
>    if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) {<br>
> -    bool IsLightweightGeneric =<br>
> -        Right.MatchingParen && Right.MatchingParen->Next &&<br>
> -        Right.MatchingParen->Next->is(tok::colon);<br>
> +    bool IsLightweightGeneric = Right.MatchingParen &&<br>
> +                                Right.MatchingParen->Next &&<br>
> +                                Right.MatchingParen->Next->is(tok::colon);<br>
>      return !IsLightweightGeneric && Style.ObjCSpaceBeforeProtocolList;<br>
>    }<br>
>    if (Right.is(tok::less) && Left.is(tok::kw_template))<br>
> @@ -2612,7 +2613,8 @@ bool TokenAnnotator::spaceRequiredBefore<br>
>      // Slashes occur in text protocol extension syntax: [type/type] { ... }.<br>
>      if (Left.is(tok::slash) || Right.is(tok::slash))<br>
>        return false;<br>
> -    if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&<br>
> +    if (Left.MatchingParen &&<br>
> +        Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&<br>
>          Right.isOneOf(tok::l_brace, tok::less))<br>
>        return !Style.Cpp11BracedListStyle;<br>
>      // A percent is probably part of a formatting specification, such as %lld.<br>
> @@ -3129,7 +3131,7 @@ bool TokenAnnotator::canBreakBefore(cons<br>
>      // function f(): a is B { ... }<br>
>      // Do not break before is in these cases.<br>
>      if (Right.is(Keywords.kw_is)) {<br>
> -      const FormatToken* Next = Right.getNextNonComment();<br>
> +      const FormatToken *Next = Right.getNextNonComment();<br>
>        // If `is` is followed by a colon, it's likely that it's a dict key, so<br>
>        // ignore it for this check.<br>
>        // For example this is common in Polymer:<br>
><br>
> Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)<br>
> +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Fri Mar  1 01:09:54 2019<br>
> @@ -6,8 +6,8 @@<br>
>  //<br>
>  //===----------------------------------------------------------------------===//<br>
><br>
> -#include "NamespaceEndCommentsFixer.h"<br>
>  #include "UnwrappedLineFormatter.h"<br>
> +#include "NamespaceEndCommentsFixer.h"<br>
>  #include "WhitespaceManager.h"<br>
>  #include "llvm/Support/Debug.h"<br>
>  #include <queue><br>
> @@ -690,10 +690,8 @@ public:<br>
>    /// Formats an \c AnnotatedLine and returns the penalty.<br>
>    ///<br>
>    /// If \p DryRun is \c false, directly applies the changes.<br>
> -  virtual unsigned formatLine(const AnnotatedLine &Line,<br>
> -                              unsigned FirstIndent,<br>
> -                              unsigned FirstStartColumn,<br>
> -                              bool DryRun) = 0;<br>
> +  virtual unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,<br>
> +                              unsigned FirstStartColumn, bool DryRun) = 0;<br>
><br>
>  protected:<br>
>    /// If the \p State's next token is an r_brace closing a nested block,<br>
> @@ -1008,13 +1006,10 @@ private:<br>
><br>
>  } // anonymous namespace<br>
><br>
> -unsigned<br>
> -UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines,<br>
> -                               bool DryRun, int AdditionalIndent,<br>
> -                               bool FixBadIndentation,<br>
> -                               unsigned FirstStartColumn,<br>
> -                               unsigned NextStartColumn,<br>
> -                               unsigned LastStartColumn) {<br>
> +unsigned UnwrappedLineFormatter::format(<br>
> +    const SmallVectorImpl<AnnotatedLine *> &Lines, bool DryRun,<br>
> +    int AdditionalIndent, bool FixBadIndentation, unsigned FirstStartColumn,<br>
> +    unsigned NextStartColumn, unsigned LastStartColumn) {<br>
>    LineJoiner Joiner(Style, Keywords, Lines);<br>
><br>
>    // Try to look up already computed penalty in DryRun-mode.<br>
><br>
> Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.h?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.h?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/UnwrappedLineFormatter.h (original)<br>
> +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.h Fri Mar  1 01:09:54 2019<br>
> @@ -39,10 +39,8 @@ public:<br>
>    /// Format the current block and return the penalty.<br>
>    unsigned format(const SmallVectorImpl<AnnotatedLine *> &Lines,<br>
>                    bool DryRun = false, int AdditionalIndent = 0,<br>
> -                  bool FixBadIndentation = false,<br>
> -                  unsigned FirstStartColumn = 0,<br>
> -                  unsigned NextStartColumn = 0,<br>
> -                  unsigned LastStartColumn = 0);<br>
> +                  bool FixBadIndentation = false, unsigned FirstStartColumn = 0,<br>
> +                  unsigned NextStartColumn = 0, unsigned LastStartColumn = 0);<br>
><br>
>  private:<br>
>    /// Add a new line and the required indent before the first Token<br>
><br>
> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)<br>
> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Mar  1 01:09:54 2019<br>
> @@ -481,7 +481,7 @@ void UnwrappedLineParser::calculateBrace<br>
>        break;<br>
>      case tok::identifier:<br>
>        if (!Tok->is(TT_StatementMacro))<br>
> -          break;<br>
> +        break;<br>
>        LLVM_FALLTHROUGH;<br>
>      case tok::at:<br>
>      case tok::semi:<br>
> @@ -1166,8 +1166,8 @@ void UnwrappedLineParser::parseStructura<br>
>        case tok::objc_synchronized:<br>
>          nextToken();<br>
>          if (FormatTok->Tok.is(tok::l_paren))<br>
> -           // Skip synchronization object<br>
> -           parseParens();<br>
> +          // Skip synchronization object<br>
> +          parseParens();<br>
>          if (FormatTok->Tok.is(tok::l_brace)) {<br>
>            if (Style.BraceWrapping.AfterControlStatement)<br>
>              addUnwrappedLine();<br>
> @@ -2350,8 +2350,7 @@ void UnwrappedLineParser::parseJavaScrip<br>
>    }<br>
>  }<br>
><br>
> -void UnwrappedLineParser::parseStatementMacro()<br>
> -{<br>
> +void UnwrappedLineParser::parseStatementMacro() {<br>
>    nextToken();<br>
>    if (FormatTok->is(tok::l_paren))<br>
>      parseParens();<br>
><br>
> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/UnwrappedLineParser.h (original)<br>
> +++ cfe/trunk/lib/Format/UnwrappedLineParser.h Fri Mar  1 01:09:54 2019<br>
> @@ -76,8 +76,7 @@ class UnwrappedLineParser {<br>
>  public:<br>
>    UnwrappedLineParser(const FormatStyle &Style,<br>
>                        const AdditionalKeywords &Keywords,<br>
> -                      unsigned FirstStartColumn,<br>
> -                      ArrayRef<FormatToken *> Tokens,<br>
> +                      unsigned FirstStartColumn, ArrayRef<FormatToken *> Tokens,<br>
>                        UnwrappedLineConsumer &Callback);<br>
><br>
>    void parse();<br>
><br>
> Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=355182&r1=355181&r2=355182&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=355182&r1=355181&r2=355182&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)<br>
> +++ cfe/trunk/lib/Format/WhitespaceManager.cpp Fri Mar  1 01:09:54 2019<br>
> @@ -432,19 +432,20 @@ void WhitespaceManager::alignConsecutive<br>
>    if (!Style.AlignConsecutiveAssignments)<br>
>      return;<br>
><br>
> -  AlignTokens(Style,<br>
> -              [&](const Change &C) {<br>
> -                // Do not align on equal signs that are first on a line.<br>
> -                if (C.NewlinesBefore > 0)<br>
> -                  return false;<br>
> -<br>
> -                // Do not align on equal signs that are last on a line.<br>
> -                if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)<br>
> -                  return false;<br>
> -<br>
> -                return C.Tok->is(tok::equal);<br>
> -              },<br>
> -              Changes, /*StartAt=*/0);<br>
> +  AlignTokens(<br>
> +      Style,<br>
> +      [&](const Change &C) {<br>
> +        // Do not align on equal signs that are first on a line.<br>
> +        if (C.NewlinesBefore > 0)<br>
> +          return false;<br>
> +<br>
> +        // Do not align on equal signs that are last on a line.<br>
> +        if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)<br>
> +          return false;<br>
> +<br>
> +        return C.Tok->is(tok::equal);<br>
> +      },<br>
> +      Changes, /*StartAt=*/0);<br>
>  }<br>
><br>
>  void WhitespaceManager::alignConsecutiveDeclarations() {<br>
> @@ -457,15 +458,16 @@ void WhitespaceManager::alignConsecutive<br>
>    //   const char* const* v1;<br>
>    //   float const* v2;<br>
>    //   SomeVeryLongType const& v3;<br>
> -  AlignTokens(Style,<br>
> -              [](Change const &C) {<br>
> -                // tok::kw_operator is necessary for aligning operator overload<br>
> -                // definitions.<br>
> -                return C.Tok->is(TT_StartOfName) ||<br>
> -                       C.Tok->is(TT_FunctionDeclarationName) ||<br>
> -                       C.Tok->is(tok::kw_operator);<br>
> -              },<br>
> -              Changes, /*StartAt=*/0);<br>
> +  AlignTokens(<br>
> +      Style,<br>
> +      [](Change const &C) {<br>
> +        // tok::kw_operator is necessary for aligning operator overload<br>
> +        // definitions.<br>
> +        return C.Tok->is(TT_StartOfName) ||<br>
> +               C.Tok->is(TT_FunctionDeclarationName) ||<br>
> +               C.Tok->is(tok::kw_operator);<br>
> +      },<br>
> +      Changes, /*StartAt=*/0);<br>
>  }<br>
><br>
>  void WhitespaceManager::alignTrailingComments() {<br>
> @@ -541,11 +543,10 @@ void WhitespaceManager::alignTrailingCom<br>
>        MinColumn = std::max(MinColumn, ChangeMinColumn);<br>
>        MaxColumn = std::min(MaxColumn, ChangeMaxColumn);<br>
>      }<br>
> -    BreakBeforeNext =<br>
> -        (i == 0) || (Changes[i].NewlinesBefore > 1) ||<br>
> -        // Never start a sequence with a comment at the beginning of<br>
> -        // the line.<br>
> -        (Changes[i].NewlinesBefore == 1 && StartOfSequence == i);<br>
> +    BreakBeforeNext = (i == 0) || (Changes[i].NewlinesBefore > 1) ||<br>
> +                      // Never start a sequence with a comment at the beginning<br>
> +                      // of the line.<br>
> +                      (Changes[i].NewlinesBefore == 1 && StartOfSequence == i);<br>
>      Newlines = 0;<br>
>    }<br>
>    alignTrailingComments(StartOfSequence, Changes.size(), MinColumn);<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>