Module Name: src Committed By: joerg Date: Sat Aug 27 18:35:21 UTC 2011
Modified Files: src/distrib/sets/lists/base: mi src/share/mk: Makefile bsd.lib.mk bsd.own.mk bsd.prog.mk Added Files: src/share/mk: bsd.clang-analyze.mk Log Message: Add new "analyze" command to run clang's static analyzer in a directory on all C/C++ files. To generate a diff of this commit: cvs rdiff -u -r1.949 -r1.950 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.43 -r1.44 src/share/mk/Makefile cvs rdiff -u -r0 -r1.1 src/share/mk/bsd.clang-analyze.mk cvs rdiff -u -r1.314 -r1.315 src/share/mk/bsd.lib.mk cvs rdiff -u -r1.680 -r1.681 src/share/mk/bsd.own.mk cvs rdiff -u -r1.265 -r1.266 src/share/mk/bsd.prog.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/base/mi diff -u src/distrib/sets/lists/base/mi:1.949 src/distrib/sets/lists/base/mi:1.950 --- src/distrib/sets/lists/base/mi:1.949 Fri Aug 26 21:22:07 2011 +++ src/distrib/sets/lists/base/mi Sat Aug 27 18:35:19 2011 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.949 2011/08/26 21:22:07 dyoung Exp $ +# $NetBSD: mi,v 1.950 2011/08/27 18:35:19 joerg Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -3739,6 +3739,7 @@ ./usr/share/misc/vgrindefs.db base-groff-share share ./usr/share/mk base-util-share ./usr/share/mk/bsd.README base-mk-share share +./usr/share/mk/bsd.clang-analyze.mk base-mk-share share ./usr/share/mk/bsd.crypto.mk base-obsolete obsolete ./usr/share/mk/bsd.dep.mk base-mk-share share ./usr/share/mk/bsd.depall.mk base-obsolete obsolete Index: src/share/mk/Makefile diff -u src/share/mk/Makefile:1.43 src/share/mk/Makefile:1.44 --- src/share/mk/Makefile:1.43 Sat Aug 7 21:50:51 2010 +++ src/share/mk/Makefile Sat Aug 27 18:35:20 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.43 2010/08/07 21:50:51 christos Exp $ +# $NetBSD: Makefile,v 1.44 2011/08/27 18:35:20 joerg Exp $ # @(#)Makefile 8.1 (Berkeley) 6/8/93 NOOBJ= # defined @@ -6,7 +6,8 @@ .include <bsd.own.mk> .if ${MKSHARE} != "no" -FILES= bsd.README bsd.dep.mk bsd.doc.mk bsd.endian.mk bsd.files.mk \ +FILES= bsd.README bsd.clang-analyze.mk bsd.dep.mk bsd.doc.mk \ + bsd.endian.mk bsd.files.mk \ bsd.gcc.mk bsd.hostlib.mk bsd.hostprog.mk bsd.inc.mk bsd.info.mk \ bsd.init.mk bsd.ioconf.mk bsd.kernobj.mk bsd.kinc.mk bsd.klinks.mk \ bsd.kmodule.mk bsd.lib.mk bsd.links.mk bsd.man.mk bsd.nls.mk \ Index: src/share/mk/bsd.lib.mk diff -u src/share/mk/bsd.lib.mk:1.314 src/share/mk/bsd.lib.mk:1.315 --- src/share/mk/bsd.lib.mk:1.314 Mon Apr 11 23:03:38 2011 +++ src/share/mk/bsd.lib.mk Sat Aug 27 18:35:20 2011 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.314 2011/04/11 23:03:38 joerg Exp $ +# $NetBSD: bsd.lib.mk,v 1.315 2011/08/27 18:35:20 joerg Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include <bsd.init.mk> @@ -776,5 +776,6 @@ .include <bsd.inc.mk> .include <bsd.links.mk> .include <bsd.dep.mk> +.include <bsd.clang-analyze.mk> ${TARGETS}: # ensure existence Index: src/share/mk/bsd.own.mk diff -u src/share/mk/bsd.own.mk:1.680 src/share/mk/bsd.own.mk:1.681 --- src/share/mk/bsd.own.mk:1.680 Thu Aug 25 00:01:25 2011 +++ src/share/mk/bsd.own.mk Sat Aug 27 18:35:20 2011 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.own.mk,v 1.680 2011/08/25 00:01:25 uwe Exp $ +# $NetBSD: bsd.own.mk,v 1.681 2011/08/27 18:35:20 joerg Exp $ # This needs to be before bsd.init.mk .if defined(BSD_MK_COMPAT_FILE) @@ -691,11 +691,11 @@ .endif TARGETS+= all clean cleandir depend dependall includes \ - install lint obj regress tags html + install lint obj regress tags html analyze PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \ install lint obj regress beforedepend afterdepend \ beforeinstall afterinstall realinstall realdepend realall \ - html subdir-all subdir-install subdir-depend + html subdir-all subdir-install subdir-depend analyze .PHONY: ${PHONY_NOTMAIN} .NOTMAIN: ${PHONY_NOTMAIN} Index: src/share/mk/bsd.prog.mk diff -u src/share/mk/bsd.prog.mk:1.265 src/share/mk/bsd.prog.mk:1.266 --- src/share/mk/bsd.prog.mk:1.265 Tue Apr 26 08:22:17 2011 +++ src/share/mk/bsd.prog.mk Sat Aug 27 18:35:20 2011 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.prog.mk,v 1.265 2011/04/26 08:22:17 he Exp $ +# $NetBSD: bsd.prog.mk,v 1.266 2011/08/27 18:35:20 joerg Exp $ # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 .ifndef HOSTPROG @@ -475,6 +475,7 @@ .include <bsd.links.mk> .include <bsd.sys.mk> .include <bsd.dep.mk> +.include <bsd.clang-analyze.mk> cleanextra: .PHONY .if defined(CLEANFILES) && !empty(CLEANFILES) Added files: Index: src/share/mk/bsd.clang-analyze.mk diff -u /dev/null src/share/mk/bsd.clang-analyze.mk:1.1 --- /dev/null Sat Aug 27 18:35:21 2011 +++ src/share/mk/bsd.clang-analyze.mk Sat Aug 27 18:35:20 2011 @@ -0,0 +1,42 @@ +# $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