HomePhabricator

[clang-format] Modified SortIncludes and IncludeCategories to priority for…

Authored by MyDeveloperDay on Sep 25 2019, 1:33 PM.

Description

[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
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

llvm-svn: 372919

Event Timeline

@Manikishan in landing this we encountered som uninitialized field warnings https://reviews.llvm.org/rL372939 which @MaskRay kindly fixed for us, what will be the impact of SortPriority being uninitialized if it's missing from someones .clang-format file?

MyDeveloperDay marked an inline comment as done.Sep 26 2019, 12:43 AM
MyDeveloperDay added inline comments.
/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
62

are there any thoughts on the impact of this being uninitialized?

@Manikishan in landing this we encountered som uninitialized field warnings https://reviews.llvm.org/rL372939 which @MaskRay kindly fixed for us, what will be the impact of SortPriority being uninitialized if it's missing from someones .clang-format file?

The changes were made in such a way that if the new field is not initialized it works as old configurations. So any old configurations won't be affected by this.

Manikishan added inline comments.Sep 26 2019, 1:08 AM
/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
62

It has no impact on old configurations in any .clang-format file that doesn't use this. Is there any way to avoid the warning ?