Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add new "analyze" command to run clang's static analyzer in ...



details:   https://anonhg.NetBSD.org/src/rev/78881a0ace08
branches:  trunk
changeset: 768818:78881a0ace08
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Aug 27 18:35:19 2011 +0000

description:
Add new "analyze" command to run clang's static analyzer in a directory
on all C/C++ files.

diffstat:

 distrib/sets/lists/base/mi    |   3 ++-
 share/mk/Makefile             |   5 +++--
 share/mk/bsd.clang-analyze.mk |  42 ++++++++++++++++++++++++++++++++++++++++++
 share/mk/bsd.lib.mk           |   3 ++-
 share/mk/bsd.own.mk           |   6 +++---
 share/mk/bsd.prog.mk          |   3 ++-
 6 files changed, 54 insertions(+), 8 deletions(-)

diffs (138 lines):

diff -r e3ad65e9f731 -r 78881a0ace08 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Sat Aug 27 18:33:22 2011 +0000
+++ b/distrib/sets/lists/base/mi        Sat Aug 27 18:35:19 2011 +0000
@@ -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
diff -r e3ad65e9f731 -r 78881a0ace08 share/mk/Makefile
--- a/share/mk/Makefile Sat Aug 27 18:33:22 2011 +0000
+++ b/share/mk/Makefile Sat Aug 27 18:35:19 2011 +0000
@@ -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 \
diff -r e3ad65e9f731 -r 78881a0ace08 share/mk/bsd.clang-analyze.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/mk/bsd.clang-analyze.mk     Sat Aug 27 18:35:19 2011 +0000
@@ -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
diff -r e3ad65e9f731 -r 78881a0ace08 share/mk/bsd.lib.mk
--- a/share/mk/bsd.lib.mk       Sat Aug 27 18:33:22 2011 +0000
+++ b/share/mk/bsd.lib.mk       Sat Aug 27 18:35:19 2011 +0000
@@ -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
diff -r e3ad65e9f731 -r 78881a0ace08 share/mk/bsd.own.mk
--- a/share/mk/bsd.own.mk       Sat Aug 27 18:33:22 2011 +0000
+++ b/share/mk/bsd.own.mk       Sat Aug 27 18:35:19 2011 +0000
@@ -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}
 
diff -r e3ad65e9f731 -r 78881a0ace08 share/mk/bsd.prog.mk
--- a/share/mk/bsd.prog.mk      Sat Aug 27 18:33:22 2011 +0000
+++ b/share/mk/bsd.prog.mk      Sat Aug 27 18:35:19 2011 +0000
@@ -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)



Home | Main Index | Thread Index | Old Index