Sat Aug 27 18:35:21 2011 UTC ()
Add new "analyze" command to run clang's static analyzer in a directory
on all C/C++ files.


(joerg)
diff -r1.949 -r1.950 src/distrib/sets/lists/base/mi
diff -r1.43 -r1.44 src/share/mk/Makefile
diff -r0 -r1.1 src/share/mk/bsd.clang-analyze.mk
diff -r1.314 -r1.315 src/share/mk/bsd.lib.mk
diff -r1.680 -r1.681 src/share/mk/bsd.own.mk
diff -r1.265 -r1.266 src/share/mk/bsd.prog.mk

cvs diff -r1.949 -r1.950 src/distrib/sets/lists/base/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/base/mi 2011/08/26 21:22:07 1.949
+++ src/distrib/sets/lists/base/mi 2011/08/27 18:35:19 1.950
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.949 2011/08/26 21:22:07 dyoung Exp $ 1# $NetBSD: mi,v 1.950 2011/08/27 18:35:19 joerg Exp $
2# 2#
3# Note: Don't delete entries from here - mark them as "obsolete" instead, 3# Note: Don't delete entries from here - mark them as "obsolete" instead,
4# unless otherwise stated below. 4# unless otherwise stated below.
5# 5#
6# Note: Do not mark "old" major and major.minor shared libraries as 6# Note: Do not mark "old" major and major.minor shared libraries as
7# "obsolete"; just remove the entry, as third-party applications 7# "obsolete"; just remove the entry, as third-party applications
8# may be linked against the old major shared library, and 8# may be linked against the old major shared library, and
9# that is a symlink to the old major.minor shared library. 9# that is a symlink to the old major.minor shared library.
10# e.g., "lib<name>.so.<N>" and "lib<name>.so.<N>.<M>" 10# e.g., "lib<name>.so.<N>" and "lib<name>.so.<N>.<M>"
11# Exceptions to this rule may include shared libraries that 11# Exceptions to this rule may include shared libraries that
12# are dlopen()ed at run-time, such as extra locales, etc. 12# are dlopen()ed at run-time, such as extra locales, etc.
13# 13#
14# /usr/bin/ident is in `base-util-bin', not `base-rcs-bin' as it is used by pkgsrc 14# /usr/bin/ident is in `base-util-bin', not `base-rcs-bin' as it is used by pkgsrc
@@ -3729,26 +3729,27 @@ @@ -3729,26 +3729,27 @@
3729./usr/share/misc/magic.mime.mgc base-obsolete obsolete 3729./usr/share/misc/magic.mime.mgc base-obsolete obsolete
3730./usr/share/misc/mail.help base-reference-share share 3730./usr/share/misc/mail.help base-reference-share share
3731./usr/share/misc/mail.tildehelp base-reference-share share 3731./usr/share/misc/mail.tildehelp base-reference-share share
3732./usr/share/misc/map3270 base-obsolete obsolete 3732./usr/share/misc/map3270 base-obsolete obsolete
3733./usr/share/misc/more.help base-obsolete obsolete 3733./usr/share/misc/more.help base-obsolete obsolete
3734./usr/share/misc/nslookup.help base-obsolete obsolete 3734./usr/share/misc/nslookup.help base-obsolete obsolete
3735./usr/share/misc/terminfo base-terminfo-share share 3735./usr/share/misc/terminfo base-terminfo-share share
3736./usr/share/misc/terminfo.db base-terminfo-share share 3736./usr/share/misc/terminfo.db base-terminfo-share share
3737./usr/share/misc/units.lib base-reference-share share 3737./usr/share/misc/units.lib base-reference-share share
3738./usr/share/misc/usb_hid_usages base-reference-share share 3738./usr/share/misc/usb_hid_usages base-reference-share share
3739./usr/share/misc/vgrindefs.db base-groff-share share 3739./usr/share/misc/vgrindefs.db base-groff-share share
3740./usr/share/mk base-util-share 3740./usr/share/mk base-util-share
3741./usr/share/mk/bsd.README base-mk-share share 3741./usr/share/mk/bsd.README base-mk-share share
 3742./usr/share/mk/bsd.clang-analyze.mk base-mk-share share
3742./usr/share/mk/bsd.crypto.mk base-obsolete obsolete 3743./usr/share/mk/bsd.crypto.mk base-obsolete obsolete
3743./usr/share/mk/bsd.dep.mk base-mk-share share 3744./usr/share/mk/bsd.dep.mk base-mk-share share
3744./usr/share/mk/bsd.depall.mk base-obsolete obsolete 3745./usr/share/mk/bsd.depall.mk base-obsolete obsolete
3745./usr/share/mk/bsd.doc.mk base-mk-share share 3746./usr/share/mk/bsd.doc.mk base-mk-share share
3746./usr/share/mk/bsd.endian.mk base-mk-share share 3747./usr/share/mk/bsd.endian.mk base-mk-share share
3747./usr/share/mk/bsd.files.mk base-mk-share share 3748./usr/share/mk/bsd.files.mk base-mk-share share
3748./usr/share/mk/bsd.gcc.mk base-mk-share share 3749./usr/share/mk/bsd.gcc.mk base-mk-share share
3749./usr/share/mk/bsd.hostlib.mk base-mk-share share 3750./usr/share/mk/bsd.hostlib.mk base-mk-share share
3750./usr/share/mk/bsd.hostprog.mk base-mk-share share 3751./usr/share/mk/bsd.hostprog.mk base-mk-share share
3751./usr/share/mk/bsd.inc.mk base-mk-share share 3752./usr/share/mk/bsd.inc.mk base-mk-share share
3752./usr/share/mk/bsd.info.mk base-mk-share share 3753./usr/share/mk/bsd.info.mk base-mk-share share
3753./usr/share/mk/bsd.init.mk base-mk-share share 3754./usr/share/mk/bsd.init.mk base-mk-share share
3754./usr/share/mk/bsd.ioconf.mk base-mk-share share 3755./usr/share/mk/bsd.ioconf.mk base-mk-share share

cvs diff -r1.43 -r1.44 src/share/mk/Makefile (expand / switch to unified diff)

--- src/share/mk/Makefile 2010/08/07 21:50:51 1.43
+++ src/share/mk/Makefile 2011/08/27 18:35:20 1.44
@@ -1,21 +1,22 @@ @@ -1,21 +1,22 @@
1# $NetBSD: Makefile,v 1.43 2010/08/07 21:50:51 christos Exp $ 1# $NetBSD: Makefile,v 1.44 2011/08/27 18:35:20 joerg Exp $
2# @(#)Makefile 8.1 (Berkeley) 6/8/93 2# @(#)Makefile 8.1 (Berkeley) 6/8/93
3 3
4NOOBJ= # defined 4NOOBJ= # defined
5 5
6.include <bsd.own.mk> 6.include <bsd.own.mk>
7 7
8.if ${MKSHARE} != "no" 8.if ${MKSHARE} != "no"
9FILES= bsd.README bsd.dep.mk bsd.doc.mk bsd.endian.mk bsd.files.mk \ 9FILES= bsd.README bsd.clang-analyze.mk bsd.dep.mk bsd.doc.mk \
 10 bsd.endian.mk bsd.files.mk \
10 bsd.gcc.mk bsd.hostlib.mk bsd.hostprog.mk bsd.inc.mk bsd.info.mk \ 11 bsd.gcc.mk bsd.hostlib.mk bsd.hostprog.mk bsd.inc.mk bsd.info.mk \
11 bsd.init.mk bsd.ioconf.mk bsd.kernobj.mk bsd.kinc.mk bsd.klinks.mk \ 12 bsd.init.mk bsd.ioconf.mk bsd.kernobj.mk bsd.kinc.mk bsd.klinks.mk \
12 bsd.kmodule.mk bsd.lib.mk bsd.links.mk bsd.man.mk bsd.nls.mk \ 13 bsd.kmodule.mk bsd.lib.mk bsd.links.mk bsd.man.mk bsd.nls.mk \
13 bsd.obj.mk bsd.own.mk bsd.prog.mk bsd.rpc.mk bsd.shlib.mk \ 14 bsd.obj.mk bsd.own.mk bsd.prog.mk bsd.rpc.mk bsd.shlib.mk \
14 bsd.subdir.mk bsd.sys.mk bsd.test.mk bsd.x11.mk sys.mk 15 bsd.subdir.mk bsd.sys.mk bsd.test.mk bsd.x11.mk sys.mk
15 16
16FILESDIR=/usr/share/mk 17FILESDIR=/usr/share/mk
17.endif 18.endif
18 19
19FILESMODE=444 20FILESMODE=444
20 21
21.include <bsd.prog.mk> 22.include <bsd.prog.mk>

File Added: src/share/mk/bsd.clang-analyze.mk
# $NetBSD: bsd.clang-analyze.mk,v 1.1 2011/08/27 18:35:20 joerg Exp $

.ifndef CLANG_ANALYZE_SRCS

CLANG_ANALYZE_FLAGS+=	-Xclang -analyze \
			-Xclang -analyzer-store=region \
			-Xclang -analyzer-opt-analyze-nested-blocks \
			-Xclang -analyzer-eagerly-assume \
			-Xclang -analyzer-checker=core \
			-Xclang -analyzer-checker=deadcode \
			-Xclang -analyzer-checker=security \
			-Xclang -analyzer-checker=unix \
			-fsyntax-only

.SUFFIXES: .c .cc .cpp .cxx .C .clang-analyzer

CLANG_ANALYZE_CFLAGS=		${CFLAGS:N-Wa,--fatal-warnings}
CLANG_ANALYZE_CXXFLAGS=	${CXXFLAGS:N-Wa,--fatal-warnings}

.c.clang-analyzer:
	${TOOL_CC.clang} ${CLANG_ANALYZE_FLAGS} \
	    ${CLANG_ANALYZE_CFLAGS} ${CPPFLAGS} \
	    ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \
	    ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
.cc.clang-analyzer .cpp.clang-analyzer .cxx.clang-analyzer .C.clang-analyzer:
	${TOOL_CXX.clang} ${CLANG_ANALYZE_FLAGS} \
	    ${CLANG_ANALYZE_CXXFLAGS} ${CPPFLAGS} \
	    ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \
	    ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}

CLANG_ANALYZE_SRCS= \
	${SRCS:M*.[cC]} ${SRCS:M*.cc} \
	${SRCS:M*.cpp} ${SRCS:M*.cxx} \
	${DPSRCS:M*.[cC]} ${DPSRCS:M*.cc} \
	${DPSRCS:M*.cpp} ${DPSRCS:M*.cxx}
.if !empty(CLANG_ANALYZE_SRCS)
CLANG_ANALYZE_OUTPUT=	${CLANG_ANALYZE_SRCS:R:S,$,.clang-analyzer,}
.endif

analyze: ${CLANG_ANALYZE_OUTPUT}

.endif

cvs diff -r1.314 -r1.315 src/share/mk/bsd.lib.mk (expand / switch to unified diff)

--- src/share/mk/bsd.lib.mk 2011/04/11 23:03:38 1.314
+++ src/share/mk/bsd.lib.mk 2011/08/27 18:35:20 1.315
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.lib.mk,v 1.314 2011/04/11 23:03:38 joerg Exp $ 1# $NetBSD: bsd.lib.mk,v 1.315 2011/08/27 18:35:20 joerg Exp $
2# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 2# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
3 3
4.include <bsd.init.mk> 4.include <bsd.init.mk>
5.include <bsd.shlib.mk> 5.include <bsd.shlib.mk>
6.include <bsd.gcc.mk> 6.include <bsd.gcc.mk>
7# Pull in <bsd.sys.mk> here so we can override its .c.o rule 7# Pull in <bsd.sys.mk> here so we can override its .c.o rule
8.include <bsd.sys.mk> 8.include <bsd.sys.mk>
9 9
10LIBISMODULE?= no 10LIBISMODULE?= no
11LIBISPRIVATE?= no 11LIBISPRIVATE?= no
12LIBISCXX?= no 12LIBISCXX?= no
13 13
14_LIB_PREFIX= lib 14_LIB_PREFIX= lib
@@ -766,15 +766,16 @@ ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: @@ -766,15 +766,16 @@ ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln:
766.endif 766.endif
767.endif # !target(libinstall) # } 767.endif # !target(libinstall) # }
768 768
769##### Pull in related .mk logic 769##### Pull in related .mk logic
770LINKSOWN?= ${LIBOWN} 770LINKSOWN?= ${LIBOWN}
771LINKSGRP?= ${LIBGRP} 771LINKSGRP?= ${LIBGRP}
772LINKSMODE?= ${LIBMODE} 772LINKSMODE?= ${LIBMODE}
773.include <bsd.man.mk> 773.include <bsd.man.mk>
774.include <bsd.nls.mk> 774.include <bsd.nls.mk>
775.include <bsd.files.mk> 775.include <bsd.files.mk>
776.include <bsd.inc.mk> 776.include <bsd.inc.mk>
777.include <bsd.links.mk> 777.include <bsd.links.mk>
778.include <bsd.dep.mk> 778.include <bsd.dep.mk>
 779.include <bsd.clang-analyze.mk>
779 780
780${TARGETS}: # ensure existence 781${TARGETS}: # ensure existence

cvs diff -r1.680 -r1.681 src/share/mk/bsd.own.mk (expand / switch to unified diff)

--- src/share/mk/bsd.own.mk 2011/08/25 00:01:25 1.680
+++ src/share/mk/bsd.own.mk 2011/08/27 18:35:20 1.681
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.own.mk,v 1.680 2011/08/25 00:01:25 uwe Exp $ 1# $NetBSD: bsd.own.mk,v 1.681 2011/08/27 18:35:20 joerg Exp $
2 2
3# This needs to be before bsd.init.mk 3# This needs to be before bsd.init.mk
4.if defined(BSD_MK_COMPAT_FILE) 4.if defined(BSD_MK_COMPAT_FILE)
5.include <${BSD_MK_COMPAT_FILE}> 5.include <${BSD_MK_COMPAT_FILE}>
6.endif 6.endif
7 7
8.if !defined(_BSD_OWN_MK_) 8.if !defined(_BSD_OWN_MK_)
9_BSD_OWN_MK_=1 9_BSD_OWN_MK_=1
10 10
11MAKECONF?= /etc/mk.conf 11MAKECONF?= /etc/mk.conf
12.-include "${MAKECONF}" 12.-include "${MAKECONF}"
13 13
14# 14#
@@ -681,31 +681,31 @@ MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH @@ -681,31 +681,31 @@ MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH
681.else 681.else
682MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd 682MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd
683.endif 683.endif
684 684
685# 685#
686# Determine if arch uses native kernel modules with rump 686# Determine if arch uses native kernel modules with rump
687# 687#
688.if ${MACHINE_ARCH} == "i386" || \ 688.if ${MACHINE_ARCH} == "i386" || \
689 ${MACHINE_ARCH} == "x86_64" 689 ${MACHINE_ARCH} == "x86_64"
690RUMPKMOD= # defined 690RUMPKMOD= # defined
691.endif 691.endif
692 692
693TARGETS+= all clean cleandir depend dependall includes \ 693TARGETS+= all clean cleandir depend dependall includes \
694 install lint obj regress tags html 694 install lint obj regress tags html analyze
695PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \ 695PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \
696 install lint obj regress beforedepend afterdepend \ 696 install lint obj regress beforedepend afterdepend \
697 beforeinstall afterinstall realinstall realdepend realall \ 697 beforeinstall afterinstall realinstall realdepend realall \
698 html subdir-all subdir-install subdir-depend 698 html subdir-all subdir-install subdir-depend analyze
699.PHONY: ${PHONY_NOTMAIN} 699.PHONY: ${PHONY_NOTMAIN}
700.NOTMAIN: ${PHONY_NOTMAIN} 700.NOTMAIN: ${PHONY_NOTMAIN}
701 701
702.if ${NEED_OWN_INSTALL_TARGET} != "no" 702.if ${NEED_OWN_INSTALL_TARGET} != "no"
703.if !target(install) 703.if !target(install)
704install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall 704install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall
705beforeinstall: 705beforeinstall:
706subdir-install: 706subdir-install:
707realinstall: 707realinstall:
708afterinstall: 708afterinstall:
709.endif 709.endif
710all: realall subdir-all 710all: realall subdir-all
711subdir-all: 711subdir-all:

cvs diff -r1.265 -r1.266 src/share/mk/bsd.prog.mk (expand / switch to unified diff)

--- src/share/mk/bsd.prog.mk 2011/04/26 08:22:17 1.265
+++ src/share/mk/bsd.prog.mk 2011/08/27 18:35:20 1.266
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.prog.mk,v 1.265 2011/04/26 08:22:17 he Exp $ 1# $NetBSD: bsd.prog.mk,v 1.266 2011/08/27 18:35:20 joerg Exp $
2# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 2# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
3 3
4.ifndef HOSTPROG 4.ifndef HOSTPROG
5 5
6.include <bsd.init.mk> 6.include <bsd.init.mk>
7.include <bsd.shlib.mk> 7.include <bsd.shlib.mk>
8.include <bsd.gcc.mk> 8.include <bsd.gcc.mk>
9 9
10# 10#
11# Definitions and targets shared among all programs built by a single 11# Definitions and targets shared among all programs built by a single
12# Makefile. 12# Makefile.
13# 13#
14 14
@@ -465,22 +465,23 @@ scriptsinstall:: @@ -465,22 +465,23 @@ scriptsinstall::
465.PHONY: scriptsinstall 465.PHONY: scriptsinstall
466 466
467##### Pull in related .mk logic 467##### Pull in related .mk logic
468LINKSOWN?= ${BINOWN} 468LINKSOWN?= ${BINOWN}
469LINKSGRP?= ${BINGRP} 469LINKSGRP?= ${BINGRP}
470LINKSMODE?= ${BINMODE} 470LINKSMODE?= ${BINMODE}
471.include <bsd.man.mk> 471.include <bsd.man.mk>
472.include <bsd.nls.mk> 472.include <bsd.nls.mk>
473.include <bsd.files.mk> 473.include <bsd.files.mk>
474.include <bsd.inc.mk> 474.include <bsd.inc.mk>
475.include <bsd.links.mk> 475.include <bsd.links.mk>
476.include <bsd.sys.mk> 476.include <bsd.sys.mk>
477.include <bsd.dep.mk> 477.include <bsd.dep.mk>
 478.include <bsd.clang-analyze.mk>
478 479
479cleanextra: .PHONY 480cleanextra: .PHONY
480.if defined(CLEANFILES) && !empty(CLEANFILES) 481.if defined(CLEANFILES) && !empty(CLEANFILES)
481 rm -f ${CLEANFILES} 482 rm -f ${CLEANFILES}
482.endif 483.endif
483 484
484${TARGETS}: # ensure existence 485${TARGETS}: # ensure existence
485 486
486.endif # HOSTPROG 487.endif # HOSTPROG