[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes
Manikishan Ghantasala via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 13 05:32:51 PDT 2019
Manikishan created this revision.
Manikishan added reviewers: cfe-commits, mgorny, christos, MyDeveloperDay.
Herald added a subscriber: krytarowski.
Herald added a project: clang.
Manikishan added subscribers: mgorny, christos.
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:**
In addition to this commit I am also adding another diff which Introduces NetBSD Style in clang-format, The required configurations are already made in this patch and can be used by
clang-format -style=NetBSD ...
(The NetBSD Style is not fully implemented but it supports SortNetBSDIncludes for now).
Here is an example how this Style sorts cpp includes according to NetBSD KNF.
**Before Formatting: **
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <net/if.h>
#include <protocols/rwhod.h>
#include <assert.h>
#include <paths.h>
#include "pathnames.h"
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
**After Formatting: **
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <netinet/in.h>
#include <protocols/rwhod.h>
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <paths.h>
#include "pathnames.h"
Repository:
rC Clang
https://reviews.llvm.org/D64695
Files:
docs/ClangFormatStyleOptions.rst
include/clang/Format/Format.h
lib/Format/Format.cpp
unittests/Format/SortIncludesTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64695.209682.patch
Type: text/x-patch
Size: 13664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190713/78c97b06/attachment-0001.bin>
More information about the cfe-commits
mailing list