Re: r372919 - [clang-format] Modified SortIncludes and IncludeCategories to priority for sorting #includes within the Group Category.
Fixed the testcase in r372944. On 2019-09-26 08:14, Mikael Holmén via cfe-commits wrote: > Hi, > > On 2019-09-26 03:16, Evgenii Stepanov via cfe-commits wrote: >> Hi, >> >> this change breaks the build with >> >> /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Format/Format.cpp:737:44: >> error: missing field 'SortPriority' initializer >> [-Werror,-Wmissing-field-initializers] >> {"^\"(llvm|llvm-c|clang|clang-c)/", 2}, > > Same thing with a testcase: > > /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:522:60: > error: missing field 'SortPriority' initializer > [-Werror,-Wmissing-field-initializers] > Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; > ^ > /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:522:71: > error: missing field 'SortPriority' initializer > [-Werror,-Wmissing-field-initializers] > Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; > ^ > /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:542:60: > error: missing field 'SortPriority' initializer > [-Werror,-Wmissing-field-initializers] > Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; > ^ > /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:542:71: > error: missing field 'SortPriority' initializer > [-Werror,-Wmissing-field-initializers] > Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; > ^ > 4 errors generated. > > /Mikael > > >> https://protect2.fireeye.com/url?k=7ed71e57-220315e9-7ed75ecc-86742d02e7e2-ebf5547e7dd70b16&q=1&u=http%3A%2F%2Flab.llvm.org%3A8011%2Fbuilders%2Fsanitizer-x86_64-linux-android%2Fbuilds%2F24667%2Fsteps%2Fbootstrap%2520clang%2Flogs%2Fstdio >> >> On Wed, Sep 25, 2019 at 1:30 PM Paul Hoad via cfe-commits >> wrote: >>> Author: paulhoad >>> Date: Wed Sep 25 13:33:01 2019 >>> New Revision: 372919 >>> >>> URL: >>> https://protect2.fireeye.com/url?k=ce962f68-924224d6-ce966ff3-86742d02e7e2-1bc81aee6f2698ad&q=1&u=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%3Frev%3D372919%26view%3Drev >>> Log: >>> [clang-format] Modified SortIncludes and IncludeCategories to priority for >>> sorting #includes within the Group Category. >>> >>> Summary: >>> This new Style rule is made as a part of adding support for NetBSD KNF in >>> clang-format. NetBSD have it's own priority of includes which should be >>> followed while formatting NetBSD code. This style sorts the Cpp Includes >>> according to the priorities of NetBSD, as mentioned in the [Style >>> Guide](https://protect2.fireeye.com/url?k=c8a250e5-94765b5b-c8a2107e-86742d02e7e2-6cc3f1b124909847&q=1&u=http%3A%2F%2Fcvsweb.netbsd.org%2Fbsdweb.cgi%2Fsrc%2Fshare%2Fmisc%2Fstyle%3Frev%3DHEAD%26content-type%3Dtext%2Fx-cvsweb-markup) >>>The working of this Style rule shown below: >>> >>> **Configuration:** >>> This revision introduces a new field under IncludeCategories named >>> `SortPriority` which defines the priority of ordering the `#includes` and >>> the `Priority` will define the categories for grouping the `#include >>> blocks`. >>> >>> Reviewers: cfe-commits, mgorny, christos, MyDeveloperDay >>> >>> Reviewed By: MyDeveloperDay >>> >>> Subscribers: lebedev.ri, rdwampler, christos, mgorny, krytarowski >>> >>> Patch By: Manikishan >>> >>> Tags: #clang, #clang-format >>> >>> Differential Revision: >>> https://protect2.fireeye.com/url?k=94716b7f-c8a560c1-94712be4-86742d02e7e2-97a1f15f4847e953&q=1&u=https%3A%2F%2Freviews.llvm.org%2FD64695 >>> >>> Modified: >>> cfe/trunk/docs/ClangFormatStyleOptions.rst >>> cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h >>> cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h >>> cfe/trunk/lib/Format/Format.cpp >>> cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp >>> cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp >>> cfe/trunk/unittests/Format/SortIncludesTest.cpp >>> >>> Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst >>> URL: >>> https://protect2.fireeye.com/url?k=d1dd6b38-8d096086-d1dd2ba3-86742d02e7e2-0c39641cd0846c27&q=1&u=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fcfe%2Ftrunk%2Fdocs%2FClangFormatStyleOptions.rst%3Frev%3D372919%26r1%3D372918%26r2%3D372919%26view%3Ddiff >>> == >>> --- cfe/trunk/docs/ClangFormatStyleOptions.rst (original) >>> +++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Sep 25 13:33:01 2019 >>> @@ -1511,6 +1511,13 @@ the configuration (without a prefix: ``A >>> can also assign negative priorities if you have certain headers that >>> always need to be first. >>> >>> + There is a
Re: r372919 - [clang-format] Modified SortIncludes and IncludeCategories to priority for sorting #includes within the Group Category.
Hi, On 2019-09-26 03:16, Evgenii Stepanov via cfe-commits wrote: > Hi, > > this change breaks the build with > > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Format/Format.cpp:737:44: > error: missing field 'SortPriority' initializer > [-Werror,-Wmissing-field-initializers] >{"^\"(llvm|llvm-c|clang|clang-c)/", 2}, Same thing with a testcase: /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:522:60: error: missing field 'SortPriority' initializer [-Werror,-Wmissing-field-initializers] Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; ^ /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:522:71: error: missing field 'SortPriority' initializer [-Werror,-Wmissing-field-initializers] Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; ^ /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:542:60: error: missing field 'SortPriority' initializer [-Werror,-Wmissing-field-initializers] Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; ^ /data/repo/master/clang/unittests/Format/SortIncludesTest.cpp:542:71: error: missing field 'SortPriority' initializer [-Werror,-Wmissing-field-initializers] Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; ^ 4 errors generated. /Mikael > https://protect2.fireeye.com/url?k=7ed71e57-220315e9-7ed75ecc-86742d02e7e2-ebf5547e7dd70b16&q=1&u=http%3A%2F%2Flab.llvm.org%3A8011%2Fbuilders%2Fsanitizer-x86_64-linux-android%2Fbuilds%2F24667%2Fsteps%2Fbootstrap%2520clang%2Flogs%2Fstdio > > On Wed, Sep 25, 2019 at 1:30 PM Paul Hoad via cfe-commits > wrote: >> Author: paulhoad >> Date: Wed Sep 25 13:33:01 2019 >> New Revision: 372919 >> >> URL: >> https://protect2.fireeye.com/url?k=ce962f68-924224d6-ce966ff3-86742d02e7e2-1bc81aee6f2698ad&q=1&u=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%3Frev%3D372919%26view%3Drev >> Log: >> [clang-format] Modified SortIncludes and IncludeCategories to priority for >> sorting #includes within the Group Category. >> >> Summary: >> This new Style rule is made as a part of adding support for NetBSD KNF in >> clang-format. NetBSD have it's own priority of includes which should be >> followed while formatting NetBSD code. This style sorts the Cpp Includes >> according to the priorities of NetBSD, as mentioned in the [Style >> Guide](https://protect2.fireeye.com/url?k=c8a250e5-94765b5b-c8a2107e-86742d02e7e2-6cc3f1b124909847&q=1&u=http%3A%2F%2Fcvsweb.netbsd.org%2Fbsdweb.cgi%2Fsrc%2Fshare%2Fmisc%2Fstyle%3Frev%3DHEAD%26content-type%3Dtext%2Fx-cvsweb-markup) >> The working of this Style rule shown below: >> >> **Configuration:** >> This revision introduces a new field under IncludeCategories named >> `SortPriority` which defines the priority of ordering the `#includes` and >> the `Priority` will define the categories for grouping the `#include blocks`. >> >> Reviewers: cfe-commits, mgorny, christos, MyDeveloperDay >> >> Reviewed By: MyDeveloperDay >> >> Subscribers: lebedev.ri, rdwampler, christos, mgorny, krytarowski >> >> Patch By: Manikishan >> >> Tags: #clang, #clang-format >> >> Differential Revision: >> https://protect2.fireeye.com/url?k=94716b7f-c8a560c1-94712be4-86742d02e7e2-97a1f15f4847e953&q=1&u=https%3A%2F%2Freviews.llvm.org%2FD64695 >> >> Modified: >> cfe/trunk/docs/ClangFormatStyleOptions.rst >> cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h >> cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h >> cfe/trunk/lib/Format/Format.cpp >> cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp >> cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp >> cfe/trunk/unittests/Format/SortIncludesTest.cpp >> >> Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst >> URL: >> https://protect2.fireeye.com/url?k=d1dd6b38-8d096086-d1dd2ba3-86742d02e7e2-0c39641cd0846c27&q=1&u=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fcfe%2Ftrunk%2Fdocs%2FClangFormatStyleOptions.rst%3Frev%3D372919%26r1%3D372918%26r2%3D372919%26view%3Ddiff >> == >> --- cfe/trunk/docs/ClangFormatStyleOptions.rst (original) >> +++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Sep 25 13:33:01 2019 >> @@ -1511,6 +1511,13 @@ the configuration (without a prefix: ``A >> can also assign negative priorities if you have certain headers that >> always need to be first. >> >> + There is a third and optional field ``SortPriority`` which can used while >> + ``IncludeBloks = IBS_Regroup`` to define the priority in which >> ``#includes`` >> + should be ordered, and value of ``Priority`` defines the order of >> + ``#inclu
Re: r372919 - [clang-format] Modified SortIncludes and IncludeCategories to priority for sorting #includes within the Group Category.
Hi, this change breaks the build with /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Format/Format.cpp:737:44: error: missing field 'SortPriority' initializer [-Werror,-Wmissing-field-initializers] {"^\"(llvm|llvm-c|clang|clang-c)/", 2}, http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/24667/steps/bootstrap%20clang/logs/stdio On Wed, Sep 25, 2019 at 1:30 PM Paul Hoad via cfe-commits wrote: > > Author: paulhoad > Date: Wed Sep 25 13:33:01 2019 > New Revision: 372919 > > URL: http://llvm.org/viewvc/llvm-project?rev=372919&view=rev > Log: > [clang-format] Modified SortIncludes and IncludeCategories to priority for > sorting #includes within the Group Category. > > Summary: > This new Style rule is made as a part of adding support for NetBSD KNF in > clang-format. NetBSD have it's own priority of includes which should be > followed while formatting NetBSD code. This style sorts the Cpp Includes > according to the priorities of NetBSD, as mentioned in the [Style > Guide](http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style?rev=HEAD&content-type=text/x-cvsweb-markup) > The working of this Style rule shown below: > > **Configuration:** > This revision introduces a new field under IncludeCategories named > `SortPriority` which defines the priority of ordering the `#includes` and the > `Priority` will define the categories for grouping the `#include blocks`. > > Reviewers: cfe-commits, mgorny, christos, MyDeveloperDay > > Reviewed By: MyDeveloperDay > > Subscribers: lebedev.ri, rdwampler, christos, mgorny, krytarowski > > Patch By: Manikishan > > Tags: #clang, #clang-format > > Differential Revision: https://reviews.llvm.org/D64695 > > Modified: > cfe/trunk/docs/ClangFormatStyleOptions.rst > cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h > cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h > cfe/trunk/lib/Format/Format.cpp > cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp > cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp > cfe/trunk/unittests/Format/SortIncludesTest.cpp > > Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=372919&r1=372918&r2=372919&view=diff > == > --- cfe/trunk/docs/ClangFormatStyleOptions.rst (original) > +++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Sep 25 13:33:01 2019 > @@ -1511,6 +1511,13 @@ the configuration (without a prefix: ``A >can also assign negative priorities if you have certain headers that >always need to be first. > > + There is a third and optional field ``SortPriority`` which can used while > + ``IncludeBloks = IBS_Regroup`` to define the priority in which > ``#includes`` > + should be ordered, and value of ``Priority`` defines the order of > + ``#include blocks`` and also enables to group ``#includes`` of different > + priority for order.``SortPriority`` is set to the value of ``Priority`` > + as default if it is not assigned. > + >To configure this in the .clang-format file, use: > >.. code-block:: yaml > @@ -1518,12 +1525,14 @@ the configuration (without a prefix: ``A > IncludeCategories: >- Regex: '^"(llvm|llvm-c|clang|clang-c)/' > Priority:2 > +SortPriority:2 >- Regex: '^(<|"(gtest|gmock|isl|json)/)' > Priority:3 >- Regex: '<[[:alnum:].]+>' > Priority:4 >- Regex: '.*' > Priority:1 > +SortPriority:0 > > **IncludeIsMainRegex** (``std::string``) >Specify a regular expression of suffixes that are allowed in the > > Modified: cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h?rev=372919&r1=372918&r2=372919&view=diff > == > --- cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h (original) > +++ cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h Wed Sep 25 > 13:33:01 2019 > @@ -32,6 +32,7 @@ public: >/// 0. Otherwise, returns the priority of the matching category or INT_MAX. >/// NOTE: this API is not thread-safe! >int getIncludePriority(StringRef IncludeName, bool CheckMainHeader) const; > + int getSortIncludePriority(StringRef IncludeName, bool CheckMainHeader) > const; > > private: >bool isMainHeader(StringRef IncludeName) const; > > Modified: cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h?rev=372919&r1=372918&r2=372919&view=diff > == > --- cfe/trunk