Import include-what-you-use. A tool that uses LLVM libraries to
determine which headers should be included based on symbols used. Can be used via make -k CC=/usr/local/bin/include-what-you-use feedback and ok jca@
This commit is contained in:
parent
10084a7e9e
commit
418b0bce6c
27
devel/include-what-you-use/Makefile
Normal file
27
devel/include-what-you-use/Makefile
Normal file
@ -0,0 +1,27 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2016/04/01 01:51:28 jsg Exp $
|
||||
|
||||
COMMENT= tool to analyse \#includes in C and C++ source files
|
||||
CATEGORIES= devel
|
||||
DISTNAME= include-what-you-use-0.5.src
|
||||
PKGNAME= include-what-you-use-0.5
|
||||
|
||||
HOMEPAGE= http://include-what-you-use.org
|
||||
MASTER_SITES= ${HOMEPAGE}/downloads/
|
||||
WRKDIST= ${WRKDIR}/include-what-you-use
|
||||
|
||||
MAINTAINER= Jonathan Gray <jsg@openbsd.org>
|
||||
|
||||
# BSD
|
||||
PERMIT_PACKAGE_CDROM= Yes
|
||||
|
||||
WANTLIB= c curses form m pthread z
|
||||
BUILD_DEPENDS= devel/llvm
|
||||
|
||||
MODULES= devel/cmake gcc4 lang/python
|
||||
MODGCC4_LANGS = c++
|
||||
MODGCC4_ARCHS = *
|
||||
CONFIGURE_ARGS= -DIWYU_LLVM_ROOT_PATH=${LOCALBASE}
|
||||
|
||||
MODPY_ADJ_FILES = fix_includes.py iwyu_tool.py
|
||||
|
||||
.include <bsd.port.mk>
|
2
devel/include-what-you-use/distinfo
Normal file
2
devel/include-what-you-use/distinfo
Normal file
@ -0,0 +1,2 @@
|
||||
SHA256 (include-what-you-use-0.5.src.tar.gz) = 7ytqYr+CRVFIu+KnESRaf9PuNqm4q0MdUNaD/WNG5Tg=
|
||||
SIZE (include-what-you-use-0.5.src.tar.gz) = 404081
|
105
devel/include-what-you-use/patches/patch-iwyu_include_picker_cc
Normal file
105
devel/include-what-you-use/patches/patch-iwyu_include_picker_cc
Normal file
@ -0,0 +1,105 @@
|
||||
$OpenBSD: patch-iwyu_include_picker_cc,v 1.1.1.1 2016/04/01 01:51:28 jsg Exp $
|
||||
--- iwyu_include_picker.cc.orig Fri Dec 11 16:45:54 2015
|
||||
+++ iwyu_include_picker.cc Mon Jan 25 12:04:44 2016
|
||||
@@ -115,8 +115,6 @@ const IncludeMapEntry libc_symbol_map[] = {
|
||||
{ "gid_t", kPrivate, "<unistd.h>", kPublic },
|
||||
{ "id_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
{ "id_t", kPrivate, "<sys/resource.h>", kPublic },
|
||||
- { "ino64_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
- { "ino64_t", kPrivate, "<dirent.h>", kPublic },
|
||||
{ "ino_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
{ "ino_t", kPrivate, "<dirent.h>", kPublic },
|
||||
{ "ino_t", kPrivate, "<sys/stat.h>", kPublic },
|
||||
@@ -132,8 +130,6 @@ const IncludeMapEntry libc_symbol_map[] = {
|
||||
{ "mode_t", kPrivate, "<sys/mman.h>", kPublic },
|
||||
{ "nlink_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
{ "nlink_t", kPrivate, "<sys/stat.h>", kPublic },
|
||||
- { "off64_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
- { "off64_t", kPrivate, "<unistd.h>", kPublic },
|
||||
{ "off_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
{ "off_t", kPrivate, "<unistd.h>", kPublic },
|
||||
{ "off_t", kPrivate, "<sys/stat.h>", kPublic },
|
||||
@@ -147,11 +143,8 @@ const IncludeMapEntry libc_symbol_map[] = {
|
||||
{ "pid_t", kPrivate, "<time.h>", kPublic },
|
||||
{ "pid_t", kPrivate, "<utmpx.h>", kPublic },
|
||||
{ "sigset_t", kPrivate, "<signal.h>", kPublic },
|
||||
- { "sigset_t", kPrivate, "<sys/epoll.h>", kPublic },
|
||||
{ "sigset_t", kPrivate, "<sys/select.h>", kPublic },
|
||||
- { "socklen_t", kPrivate, "<bits/socket.h>", kPrivate },
|
||||
- { "socklen_t", kPrivate, "<unistd.h>", kPublic },
|
||||
- { "socklen_t", kPrivate, "<arpa/inet.h>", kPublic },
|
||||
+ { "socklen_t", kPrivate, "<sys/socket.h>", kPublic },
|
||||
{ "ssize_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
{ "ssize_t", kPrivate, "<unistd.h>", kPublic },
|
||||
{ "ssize_t", kPrivate, "<monetary.h>", kPublic },
|
||||
@@ -179,6 +172,7 @@ const IncludeMapEntry libc_symbol_map[] = {
|
||||
{ "size_t", kPrivate, "<string.h>", kPublic },
|
||||
{ "size_t", kPrivate, "<time.h>", kPublic },
|
||||
{ "size_t", kPrivate, "<wchar.h>", kPublic },
|
||||
+ { "size_t", kPrivate, "<sys/types.h>", kPublic },
|
||||
// Macros that can be defined in more than one file, don't have the
|
||||
// same __foo_defined guard that other types do, so the grep above
|
||||
// doesn't discover them. Until I figure out a better way, I just
|
||||
@@ -192,6 +186,10 @@ const IncludeMapEntry libc_symbol_map[] = {
|
||||
{ "calloc", kPrivate, "<stdlib.h>", kPublic },
|
||||
{ "realloc", kPrivate, "<stdlib.h>", kPublic },
|
||||
{ "free", kPrivate, "<stdlib.h>", kPublic },
|
||||
+ { "htonl", kPrivate, "<arpa/inet.h>", kPublic },
|
||||
+ { "htons", kPrivate, "<arpa/inet.h>", kPublic },
|
||||
+ { "ntohl", kPrivate, "<arpa/inet.h>", kPublic },
|
||||
+ { "ntohs", kPrivate, "<arpa/inet.h>", kPublic },
|
||||
// Entries for NULL
|
||||
{ "NULL", kPrivate, "<stddef.h>", kPublic }, // 'canonical' location for NULL
|
||||
{ "NULL", kPrivate, "<clocale>", kPublic },
|
||||
@@ -237,7 +235,7 @@ const IncludeMapEntry libstdcpp_symbol_map[] = {
|
||||
};
|
||||
|
||||
// Private -> public include mappings for GNU libc
|
||||
-const IncludeMapEntry libc_include_map[] = {
|
||||
+const IncludeMapEntry glibc_include_map[] = {
|
||||
// ( cd /usr/include && grep '^ *# *include' {sys/,net/,}* | perl -nle 'm/^([^:]+).*<([^>]+)>/ && print qq@ { "<$2>", kPrivate, "<$1>", kPublic },@' | grep bits/ | sort )
|
||||
// When I saw more than one mapping for these, I typically picked
|
||||
// what I thought was the "best" one.
|
||||
@@ -436,6 +434,42 @@ const IncludeMapEntry libc_include_map[] = {
|
||||
{ "<linux/limits.h>", kPrivate, "<limits.h>", kPublic }, // PATH_MAX
|
||||
{ "<linux/prctl.h>", kPrivate, "<sys/prctl.h>", kPublic },
|
||||
{ "<sys/ucontext.h>", kPrivate, "<ucontext.h>", kPublic },
|
||||
+};
|
||||
+
|
||||
+// Private -> public include mappings for OpenBSD libc
|
||||
+const IncludeMapEntry libc_include_map[] = {
|
||||
+ { "<machine/_float.h>", kPrivate, "<float.h>", kPublic },
|
||||
+ { "<machine/_types.h>", kPrivate, "<sys/_types.h>", kPrivate },
|
||||
+ { "<machine/atomic.h>", kPrivate, "<sys/atomic.h>", kPublic },
|
||||
+ { "<machine/cdefs.h>", kPrivate, "<sys/cdefs.h>", kPublic },
|
||||
+ { "<machine/disklabel.h>", kPrivate, "<sys/disklabel.h>", kPublic },
|
||||
+ { "<machine/endian.h>", kPrivate, "<sys/endian.h>", kPrivate },
|
||||
+ { "<machine/limits.h>", kPrivate, "<sys/limits.h>", kPrivate },
|
||||
+ { "<machine/param.h>", kPrivate, "<sys/param.h>", kPublic },
|
||||
+ { "<machine/ptrace.h>", kPrivate, "<sys/ptrace.h>", kPublic },
|
||||
+ { "<machine/signal.h>", kPrivate, "<sys/signal.h>", kPrivate },
|
||||
+ { "<machine/stdarg.h>", kPrivate, "<sys/stdarg.h>", kPrivate },
|
||||
+ { "<machine/stdint.h>", kPrivate, "<sys/stdint.h>", kPrivate },
|
||||
+ { "<machine/varargs.h>", kPrivate, "<sys/varags.h>", kPrivate },
|
||||
+ { "<netinet6/in6.h>", kPrivate, "<netinet/in.h>", kPublic },
|
||||
+ { "<sys/_endian.h>", kPrivate, "<sys/endian.h>", kPrivate },
|
||||
+ { "<sys/_time.h>", kPrivate, "<time.h>", kPublic },
|
||||
+ { "<sys/_types.h>", kPrivate, "<sys/types.h>", kPublic },
|
||||
+ { "<sys/endian.h>", kPrivate, "<endian.h>", kPublic },
|
||||
+ { "<sys/dirent.h>", kPrivate, "<dirent.h>", kPublic },
|
||||
+ { "<sys/errno.h>", kPrivate, "<errno.h>", kPublic },
|
||||
+ { "<sys/fcntl.h>", kPrivate, "<fcntl.h>", kPublic },
|
||||
+ { "<sys/limits.h>", kPrivate, "<limits.h>", kPublic },
|
||||
+ { "<sys/poll.h>", kPrivate, "<poll.h>", kPublic },
|
||||
+ { "<sys/signal.h>", kPrivate, "<signal.h>", kPublic },
|
||||
+ { "<sys/stdarg.h>", kPrivate, "<stdarg.h>", kPublic },
|
||||
+ { "<sys/stdint.h>", kPrivate, "<stdint.h>", kPublic },
|
||||
+ { "<sys/syslimits.h>", kPrivate, "<limits.h>", kPublic },
|
||||
+ { "<sys/syslog.h>", kPrivate, "<syslog.h>", kPublic },
|
||||
+ { "<sys/termios.h>", kPrivate, "<termios.h>", kPublic },
|
||||
+ { "<sys/unistd.h>", kPrivate, "<unistd.h>", kPublic },
|
||||
+ { "<sys/uuid.h>", kPrivate, "<uuid.h>", kPublic },
|
||||
+ { "<sys/varargs.h>", kPrivate, "<varargs.h>", kPublic },
|
||||
};
|
||||
|
||||
const IncludeMapEntry stdlib_c_include_map[] = {
|
11
devel/include-what-you-use/pkg/DESCR
Normal file
11
devel/include-what-you-use/pkg/DESCR
Normal file
@ -0,0 +1,11 @@
|
||||
Include what you use means this: for every symbol (type, function
|
||||
variable, or macro) that you use in foo.cc, either foo.cc or foo.h
|
||||
should #include a .h file that exports the declaration of that symbol.
|
||||
The include-what-you-use tool is a program that can be built with the
|
||||
clang libraries in order to analyze #includes of source files to find
|
||||
include-what-you-use violations, and suggest fixes for them.
|
||||
|
||||
The main goal of include-what-you-use is to remove superfluous
|
||||
#includes. It does this both by figuring out what #includes are not
|
||||
actually needed for this file (for both .cc and .h files), and replacing
|
||||
#includes with forward-declares when possible.
|
4
devel/include-what-you-use/pkg/PLIST
Normal file
4
devel/include-what-you-use/pkg/PLIST
Normal file
@ -0,0 +1,4 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2016/04/01 01:51:28 jsg Exp $
|
||||
bin/fix_includes.py
|
||||
@bin bin/include-what-you-use
|
||||
bin/iwyu_tool.py
|
Loading…
Reference in New Issue
Block a user