[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes
Ronald Wampler via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 10:40:57 PDT 2019
rdwampler added a comment.
> Sorry, my mistake I meant that I have added Regex for priorities while sorting and If I am not wrong I think IncludeCategories are used while Regrouping after sorting the Includes. In addition to that in my case I have to sort the includes In a particular order then grouping them in different
> For example:
>
> #include <sys/param.h> /* <sys/param.h> first, */
> #include <sys/types.h> /* <sys/types.h> next, */
> #include <sys/ioctl.h> /* and then the rest, */
> #include <uvm/*.h>
> #include <dev/*.h>
>
> #include <net/if.h>
> #include <net/if_dl.h>
> #include <net/route.h>
> #include <netinet/in.h>
> #include <protocols/rwhod.h>
>
>
>
> As shown in the above example <uvm> should follow <sys> then <dev> but while regrouping they should be in the same group.
OK. I think I understand. Since <sys/param.h> and <sys/types.h> have to come first we would need to set the regex and priorities for those individually. But then those will be treated as separate block and grouped like:
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ioctl.h>
more <sys/*> includes
I wonder if a better approach would be to extend `IncludeCatalog` to allow the grouping to specified independent of the regex?
E.g., { "{<sys/param.h>", 0, 1 }, // priority 1, group 1
{<sys/types.h>, 1, 1, }, // different priority, but same group
{<sys/*>, 2, 1} // more general headers with lower priority, but will still be grouped in group 1.
}
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64695/new/
https://reviews.llvm.org/D64695
More information about the cfe-commits
mailing list